Overview
In this guide, Filter allows you to filter a field to an approximate value
The Equals filter allows you to check fields for an exact value. The following SQL statement is executed in the background: WHERE stock = 10.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter(‘stock’, 10));
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “equals”,
“field”: “stock”,
“value”: 10
}
]
}
{% endtab %} {% endtabs %}
The EqualsAny filter allows you to filter a field where at least one of the defined values matches exactly. The following SQL statement is executed in the background: WHERE productNumber IN (‘3fed029475fa4d4585f3a119886e0eb1′, ’77d26d011d914c3aa2c197c81241a45b’).
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(
new EqualsAnyFilter(‘productNumber’, [‘3fed029475fa4d4585f3a119886e0eb1′, ’77d26d011d914c3aa2c197c81241a45b’])
);
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “equalsAny”,
“field”: “productNumber”,
“value”: [
“3fed029475fa4d4585f3a119886e0eb1”,
“77d26d011d914c3aa2c197c81241a45b”
]
}
]
}
{% endtab %} {% endtabs %}
The Contains Filter allows you to filter a field to an approximate value, where the passed value must be contained as a full value. The following SQL statement is executed in the background: WHERE name LIKE ‘%Lightweight%’.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(new ContainsFilter(‘name’, ‘Lightweight’));
);
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “contains”,
“field”: “name”,
“value”: “Lightweight”
}
]
}
{% endtab %} {% endtabs %}
The Range filter allows you to filter a field to a value space. This can work with a date or numerical values. Within the parameter property the following values are possible:
The following SQL statement is executed in the background: WHERE stock >= 20 AND stock <= 30.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(
new RangeFilter(‘stock’, [
RangeFilter::GTE => 20,
RangeFilter::LTE => 30
])
);
);
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “range”,
“field”: “stock”,
“parameters”: {
“gte”: 20,
“lte”: 30
}
}
]
}
{% endtab %} {% endtabs %}
The Not Filter is a container which allows to negate any kind of filter. The operator allows you to define the combination of queries within the NOT filter (OR and AND). The following SQL statement is executed in the background: WHERE !(stock = 1 OR availableStock = 1) AND active = 1.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter(‘active’, true));
$criteria->addFilter(
new NotFilter(
NotFilter::CONNECTION_OR,
[
new EqualsFilter(‘stock’, 1),
new EqualsFilter(‘availableStock’, 10)
]
)
);
);
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “not”,
“operator”: “or”,
“queries”: [
{
“type”: “equals”,
“field”: “stock”,
“value”: 1
},
{
“type”: “equals”,
“field”: “availableStock”,
“value”: 1
}
]
},
{
“type”: “equals”,
“field”: “active”,
“value”: true
}
]
}
{% endtab %} {% endtabs %}
The Multi Filter is a container, which allows to set logical links between filters. The operator allows you to define the links between the queries within the Multi filter (OR and AND). The following SQL statement is executed in the background: WHERE (stock = 1 OR availableStock = 1) AND active = 1.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(
new MultiFilter(
MultiFilter::CONNECTION_OR,
[
new EqualsFilter(‘stock’, 1),
new EqualsFilter(‘availableStock’, 10)
]
)
);
$criteria->addFilter(
new EqualsFilter(‘active’, true)
);
);
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “multi”,
“operator”: “or”,
“queries”: [
{
“type”: “equals”,
“field”: “stock”,
“value”: 1
},
{
“type”: “equals”,
“field”: “availableStock”,
“value”: 1
}
]
},
{
“type”: “equals”,
“field”: “active”,
“value”: true
}
]
}
{% endtab %} {% endtabs %}
The Prefix Filter allows you to filter a field to an approximate value, where the passed value must be the start of a full value. The following SQL statement is executed in the background: WHERE name LIKE ‘Lightweight%’.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(new PrefixFilter(‘name’, ‘Lightweight’));
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “prefix”,
“field”: “name”,
“value”: “Lightweight”
}
]
}
{% endtab %} {% endtabs %}
The Suffix Filter allows you to filter a field to an approximate value, where the passed value must be an end of a full value. The following SQL statement is executed in the background: WHERE name LIKE ‘%Lightweight’.
{% tabs %} {% tab title=”PHP Criteria” %}
$criteria = new Criteria();
$criteria->addFilter(new SuffixFilter(‘name’, ‘Lightweight’));
{% endtabs %}
{% tab title=”API Criteria” %}
{
“filter”: [
{
“type”: “suffix”,
“field”: “name”,
“value”: “Lightweight”
}
]
}
{% endtab %} {% endtabs %}
It was expected outcome and timely delivered. They are good at communication and client services. Project was smooth enough to develop, communication was excellent. They always ask too many question to reach the correct destination. Would like to hire them again for next Business.
The team manages the project transparently and keeps an open line of communication. In addition to going above and beyond, they're also able to relay technical information in layman's terms.
They offered a number of possibilities which I didn't expect while customizing a standard Shopware Theme.
The team is knowledgeable and always answered all my queries in the timely manner. I would recommend them for affordable and safe migration services.