Querying Products by Custom Properties in Ucommerce
One of the questions I’ve come across a couple of times with Ucommerce is using the LINQ API to query products by custom properties added to a product definition.
Here’s how:
1 2 3 4 5 6 7 8 | var q = from product in Product.All() where product.ProductProperties.Where(property => (property.ProductDefinitionField.Name == "MyProperty" && property.Value == "MyPropertyValue" ) || (property.ProductDefinitionField.Name == "MyOtherProperty" && property.Value == "MyotherPropertyValue" )).Count() == 2 && product.ParentProductId == null select product; |