Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

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:

    
    
    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;