Previously I was using a multiple content picker in order to allow my editors to specify a list of related products to show on a product page. With 1.12.0 I can obviously no longer use this as products are not in the umbraco tree any more.
Is there a way to achieve similar functionality in 1.12.0? I have tried adding a merchello product selector to an archetype but it doesn't appear to work unfortunately. I have looked at the product list view but this seems to only work with collections which I think is a bit overkill for a related products selector.
I case anyone is interested and stumbles across this in the future. I resorted to having a multiple text box and having the customer specify skus that they wanted to show in the end.
It's nothing more than a standard umbraco multiple textbox which the customer adds the skus to. In the razor template I use the following in a repeater:
@foreach (var relatedProduct in product.GetPropertyValue<string>("relatedProducts").Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Where(x => x != product.Sku && Merchello.Query.Product.GetBySku(x).Available).Select(x => Merchello.TypedProductContent(Merchello.Query.Product.GetBySku(x).Key)) { Template Stuff Here }
Fantastic, thanks. I've never used the nested content plugin. Might be using it a bit more often from now on!! Took a few minutes to get my head around how it worked, the key part I was missing was creating the document type for a related product.
The only thing I couldn't work out was what to put in the Name template field on the nested content data type form. I tried {{product}} (product being my product selector field) but that just gives me the merchello product key. Is there any way to get the actual product name that was selected?
I've not had any success as yet getting the product name into the item name template using Nested Content but using nested content to get multiple related items works quite well as a solution to this problem. Also, I have found that you can simply us GetPropertyValue<ProductDisplay>("Product") to get the selected product from the property on the doctype used in the NestedContent datatype, I assume this is through the power of ContentConvertors that might now be included in the package making this sort of ting possible:
var relatedProducts = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("RelatedProductsProperty");
@foreach (var relatedProduct in relatedProducts)
{
var product = relatedProduct.GetPropertyValue<ProductDisplay>("Product");
var productContent = product.AsProductContent();
var img = productContent.GetPropertyValue<IPublishedContent>("image");
// Do your stuff here...
}
... this saves having to mess around MerchelloHelper and querying products.
Hopefully someone can solve the problem with the product title appearing as the nested content item title and this will be a perfect solution for me!
Related Product Selector in 1.12.0
Previously I was using a multiple content picker in order to allow my editors to specify a list of related products to show on a product page. With 1.12.0 I can obviously no longer use this as products are not in the umbraco tree any more.
Is there a way to achieve similar functionality in 1.12.0? I have tried adding a merchello product selector to an archetype but it doesn't appear to work unfortunately. I have looked at the product list view but this seems to only work with collections which I think is a bit overkill for a related products selector.
Thanks
Chris
I case anyone is interested and stumbles across this in the future. I resorted to having a multiple text box and having the customer specify skus that they wanted to show in the end.
Hi Chris,
Could you share your method please?
I have the same issue where I need to create a related events/product picker. Tried using Nester Content document type, but can't get get it to work.
Thanks,
Paulius
Hi Konijus,
It's nothing more than a standard umbraco multiple textbox which the customer adds the skus to. In the razor template I use the following in a repeater:
Chris
Hi Chris,
Thanks for the answer.
I managed to get it to work with Nested content. Code below:
Not sure if you need all namespaces at the top. It's just something I got working.
Related product uses Merchello Product Selector data type so you can use it to get list of products, search. Please find screen grab attached.
Fantastic, thanks. I've never used the nested content plugin. Might be using it a bit more often from now on!! Took a few minutes to get my head around how it worked, the key part I was missing was creating the document type for a related product.
The only thing I couldn't work out was what to put in the Name template field on the nested content data type form. I tried {{product}} (product being my product selector field) but that just gives me the merchello product key. Is there any way to get the actual product name that was selected?
Thanks
Chris
I've not had any success as yet getting the product name into the item name template using Nested Content but using nested content to get multiple related items works quite well as a solution to this problem. Also, I have found that you can simply us
GetPropertyValue<ProductDisplay>("Product")
to get the selected product from the property on the doctype used in the NestedContent datatype, I assume this is through the power of ContentConvertors that might now be included in the package making this sort of ting possible:... this saves having to mess around
MerchelloHelper
and querying products.Hopefully someone can solve the problem with the product title appearing as the nested content item title and this will be a perfect solution for me!
is working on a reply...