getProductsCount
Get the count of all products with optional filters.
Description
Counts the products that match the filter conditions in body. Resolves to an IProductsCount with totalAll, totalInCategory and totalInCategoryWithNested.
.getProductsCount(
);
Parameters schema
Schema
body: any[]
Filter objects with search conditions. Default: [].
example:
[
{
"attributeMarker": "price",
"conditionMarker": "in",
"statusMarker": "status_1",
"conditionValue": {},
"pageUrls": [
"23-laminat-floorwood-maxima"
],
"title": "Iphone 17 Pro"
}
]
Examples
Minimal example
const response = await Products.getProductsCount();
Example with filters
const response = await Products.getProductsCount([
{ attributeMarker: 'price', conditionMarker: 'mth', conditionValue: 100 },
]);
Use filters to find specific products count:
attributeMarker: The text identifier of the indexed attribute by which values are filtered. conditionMarker: The type of condition to apply to the attribute value.
| Marker | Meaning | Example |
|---|---|---|
| eq | Equal | color = "red" |
| neq | Not equal | category ≠ "archived" |
| in | Contains (case-insensitive substring match) | brand contains "app" |
| nin | Does not contain (case-insensitive substring match) | brand does not contain "fake" |
| mth | Greater than | price > 100 |
| lth | Less than | price < 50 |
| exs | Exists (has value) | Has description |
| nexs | Does not exist | No image |
| pat | Matches a regular-expression pattern where each * stands for exactly one character and _ for a space. With search indexing on, the pattern must match the whole value | currency matches "s" (finds "usd") |
| same | Has the same value as at least one other product. conditionValue is ignored | products that share a price |
| same_part | Has the same value as another product once the last segments are cut off. conditionValue is delimiter|count (default -|2); a value with count or fewer segments is compared whole | SKUs "ABC-1-S" and "ABC-1-M" share "ABC" |
conditionValue: The value to compare against.
Example response
{
"totalAll": 6,
"totalInCategory": 0,
"totalInCategoryWithNested": 0
}
Response schema
Schema: IProductsCount
totalAll: number
Number of matching visible products in the whole catalog, on any page.
example: 100
totalInCategory: number
Number of matching products on the catalog page itself. Always 0 for getProductsCount, which has no page.
example: 50
totalInCategoryWithNested: number
Number of matching products on the catalog page and its nested categories. Always 0 for getProductsCount, which has no page.
example: 10
Usage examples
Step-by-step walkthrough in the documentation:
- Get products count: get the total number of products, optionally filtered.
Try it live
Run this method in the JS SDK sandbox. On your first visit, connect your Project URL and App Token, then open:
- Get products count: get the total number of products, optionally filtered.