I have created a module Products and content type product. I am creating a custom widget to display a single product. I have setup my designer and once I drop the widget on a page I can select from the product list using the sf-list-selector sf-dynamic-items-selector. My issue is matching that item ID to the list of products my widget is pulling up. Here is the code the widget uses to retrieve all products:
var dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
var contentType = TypeResolutionService.ResolveType(typeName);
var contentElements = dynamicModuleManager.GetDataItems(contentType).Where(x => x.Status == ContentLifecycleStatus.Live);
products = contentElements.ToArray().Select(p => new ItemViewModel(p)).ToArray();
This works good and pulls up the list of products. The question is how to filter this list using the selected product id from the designer. I have this and they don't match:
products.Single(p => p.DataItem.Id == Guid.Parse(selectedProductId))
How do I go from the ItemViewModel to the Id the selector is giving me?
using Feather 9.1
Instead of getting a list of itemviewmodel first, did so:
var contentElement = dynamicModuleManager.GetDataItem(contentType, Guid.Parse(selectedProductId));
product = new ItemViewModel(dynamicModuleManager.Lifecycle.GetLive(contentElement));
Ps: Apparently the dynamic selector returns the Id of the master version of the content which I did not understand initially what Id it was returning.