How toWeb Service Developer Guide

Web Service Developer Guide

Sana Commerce 9.0
Your connector

Filtering on Several Fields

To specify a filter for a certain field of the Product entity you need to fill the Filter node in the request with the FieldCriteriaItem nodes. One FieldCriteriaItem node represents a filter for one Product field.

For example, if you want to filter products by the 'Title' field, you need to add one FieldCriteriaItem node:

XML JSON
<Filter>
 <fields>
  <dictionary>
   <FieldCriteriaItem>
    <Key>Title</Key>
    <Value>
     <Field>Title</Field>
     <Options>
       <!-- criterion list -->
     </Options>
    </Value>
   </FieldCriteriaItem>
  </dictionary>
 </fields>
</Filter>
    "Filter":
    {
        "fields":
        {
            "dictionary":
            [{
                "Key":"Title",
                "Value":
                {
                    "Field":"Title",
                    "Options":
                    [ /* criterion list */ ]
                }
            }]
        }
    }

As shown in the example above the field name 'Title', to which the filter is applied, must be specified in the FieldCriteriaItem/Key element and also in the FieldCriteriaItem/Value/Field element.
 
In the example below you can see how to specify the filter for two different fields of the Product entity, the 'Title' and 'Id' fields. In this case you need to add two FieldCriteriaItem nodes, one for the 'Title' field and another for the 'Id' field:

XML JSON
<Filter>
 <fields>
  <dictionary>
   <FieldCriteriaItem>
    <Key>Id</Key>
    <Value>
     <Field>Id</Field>
     <Options>
       <!-- criterion list for the Id field -->
     </Options>
    </Value>
   </FieldCriteriaItem>
   <FieldCriteriaItem>
    <Key>Title</Key>
    <Value>
     <Field>Title</Field>
     <Options>
       <!-- criterion list for the Title field -->
     </Options>
    </Value>
   </FieldCriteriaItem>
  </dictionary>
 </fields>
</Filter>
    "Filter":
    {
        "fields":
        {
            "dictionary":
            [{
                "Key":"Id",
                "Value":
                {
                    "Field":"Id",
                    "Options":
                    [ /* criterion list for the Id field */ ]
                }
            },
            {
                "Key":"Title",
                "Value":
                {
                    "Field":"Title",
                    "Options":
                    [ /* criterion list for the Title field */ ]
                }
            }]
        }
    }

Thus any number of FieldCriteriaItem nodes can be added, each applied to a certain field of the Product entity.

How toWeb Service Developer Guide