I'm having trouble figuring out how the name on an order line / product snapshot gets generated for a products (using the default UmbracoProductAdapter), and I'm wondering if there is anyway I can override this default logic. I'm on Vendr 2.1 on Umbraco 9.
Currently, when users add a child variant to the cart, the Order Line item name is just showing the product name instead of the product name with the name variant. I'm assuming this name comes from the Product Snapshot name, since the snapshot name is also missing this and i can't seem to figure out how to make it include that.
I do have my variants setup a little different than like the demo site, in that the main product doesn't have a sku/price/stock - only the child variants do - since this was confusing to the authors. I'm not sure if that matters, but I thought I'd mention that.
It looks like I could make a new Snapshot object class and product adapter, but I don't really want to have to mimc all of the logic, and so I'm hoping there's some way to just override the name logic. Or I'm hoping there's some other way I can set this up to include the variant name.
You'll probably actually want to inherit from the default one UmbracoProductNameExtractor and just override the second method (by default the first method just proxies to the second with a null variandeContent param)
From there you can extract whatever you want to use from both the parent node and the variant item.
We got a product structure of up to 3 levels. The product set changes frequently, and product cockpit users modify content of the Base Product without considering the impact it causes to Base Product variants, i.e change product name and leave the old name under the variants etc
Child Variant Product Name Logic
I'm having trouble figuring out how the name on an order line / product snapshot gets generated for a products (using the default UmbracoProductAdapter), and I'm wondering if there is anyway I can override this default logic. I'm on Vendr 2.1 on Umbraco 9.
Currently, when users add a child variant to the cart, the Order Line item name is just showing the product name instead of the product name with the name variant. I'm assuming this name comes from the Product Snapshot name, since the snapshot name is also missing this and i can't seem to figure out how to make it include that.
I do have my variants setup a little different than like the demo site, in that the main product doesn't have a sku/price/stock - only the child variants do - since this was confusing to the authors. I'm not sure if that matters, but I thought I'd mention that.
It looks like I could make a new Snapshot object class and product adapter, but I don't really want to have to mimc all of the logic, and so I'm hoping there's some way to just override the name logic. Or I'm hoping there's some other way I can set this up to include the variant name.
Hey Kevin,
Sure, you can implement a custom
IUmbracoProductNameExtractor
to override the name extracted by the default product adapter.You'll probably actually want to inherit from the default one
UmbracoProductNameExtractor
and just override the second method (by default the first method just proxies to the second with a null variandeContent param)From there you can extract whatever you want to use from both the parent node and the variant item.
See the docs on replacing dependencies for how to register this https://vendr.net/docs/core/2.1.0/umbraco-v9/key-concepts/dependency-injection/#replacing-dependencies
We got a product structure of up to 3 levels. The product set changes frequently, and product cockpit users modify content of the Base Product without considering the impact it causes to Base Product variants, i.e change product name and leave the old name under the variants etc
Fortiva Credit Card
is working on a reply...