I am using the Merchello 2.2.1 and having an issues with getting a product collection from a detached content type.
I created a doctype with a product collection picker which is set as the extended content type of a product. I am then trying to pull a list of the products from that collection inside a merchello surface controller.
The value returned from the ProductCollectionPicker should be, I think, the collection key and that should be a GUID.
The problem is that it is 33 characters instead of 32 and I cannot use it to get a list of products. What am I missing?
Error:
Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
MemberProduct is an IProduct
var extendedContent = MemberProduct.DetachedContents.FirstOrDefault();
var certCollectionProperty = extendedContent
.DetachedDataValues
.FirstOrDefault(c => c.Key.ToLowerInvariant().Equals("certifications"));
var certCollectionKey = Guid.Parse(certCollectionProperty.Value);
var certList = MerchelloServices
.ProductService
.GetFromCollection(certCollectionKey, 1, int.MaxValue, "Sku", SortDirection.Ascending)
.Items
.ToSelectList(p => $"{p.Price.ToString("C")} - {p.Name}", p => p.Sku, SelectListPrompt);
Please ignore the need to refactor FYI - This is not the final code just figuring things out.
Product Collection Key too long
I am using the Merchello 2.2.1 and having an issues with getting a product collection from a detached content type.
I created a doctype with a product collection picker which is set as the extended content type of a product. I am then trying to pull a list of the products from that collection inside a merchello surface controller.
The value returned from the ProductCollectionPicker should be, I think, the collection key and that should be a GUID.
The problem is that it is 33 characters instead of 32 and I cannot use it to get a list of products. What am I missing?
Error: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
MemberProduct is an IProduct
Please ignore the need to refactor FYI - This is not the final code just figuring things out.
Doh! The key value is quoted... completely missed that...
is working on a reply...