I have a Category doctype that has products associated with it using the Merchello Product List View. My product template uses the virtual IProductContent so I cannot navigate up the Umbraco tree from the product template.
I'd like to use a shared header and footer in my template however those require the ability to traverse the Umbraco tree.
Is it possible to give these virtual products a parent so the umbraco tree can be traversed.
As products can be in more than one category, I thought it may be possible to have a property on my Product doctype that allows a "Primary Category" to be selected. However I don't know how / where I would select this property and set it to be the product's parent.
I found you can set the parent for virtual content in the ProductContentFactoryOnInitializing (still not sure how to set the parent for each individual product).
I'm having problems now when I set the parent to my root store node, all the extended product properties are null.
This is the code of my event
private static void ProductContentFactoryOnInitializing(ProductContentFactory sender, VirtualContentEventArgs e)
{
UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var store = umbracoHelper.TypedContentSingleAtXPath("//store");
e.Parent = store;
}
As far as I can see I'm not doing anything different from FastTrack yet my extended properties are null while on FastTrack they have a value.
For anyone finding this thread that is wondering something similar I'll note how I solved the issues in case it helps.
On my Product doc type I've added a "Primary Category" content picker where the products main category can be selected. I don't set this to be the Parent of the product though, instead that is set to the store node and anywhere I need the category I just retrieve it from the product's extended data.
I also managed to resolve the issue with the extended properties being null by removing the protection from the store (the store is only available to members) then re-applying the protection.
Set parent of product to category
I have a Category doctype that has products associated with it using the Merchello Product List View. My product template uses the virtual IProductContent so I cannot navigate up the Umbraco tree from the product template.
I'd like to use a shared header and footer in my template however those require the ability to traverse the Umbraco tree.
Is it possible to give these virtual products a parent so the umbraco tree can be traversed.
As products can be in more than one category, I thought it may be possible to have a property on my Product doctype that allows a "Primary Category" to be selected. However I don't know how / where I would select this property and set it to be the product's parent.
I found you can set the parent for virtual content in the ProductContentFactoryOnInitializing (still not sure how to set the parent for each individual product).
I'm having problems now when I set the parent to my root store node, all the extended product properties are null.
This is the code of my event
As far as I can see I'm not doing anything different from FastTrack yet my extended properties are null while on FastTrack they have a value.
Can anyone help with this?
For anyone finding this thread that is wondering something similar I'll note how I solved the issues in case it helps.
On my Product doc type I've added a "Primary Category" content picker where the products main category can be selected. I don't set this to be the Parent of the product though, instead that is set to the store node and anywhere I need the category I just retrieve it from the product's extended data.
I also managed to resolve the issue with the extended properties being null by removing the protection from the store (the store is only available to members) then re-applying the protection.
is working on a reply...