Skip to main content

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.

MarkerMeaningExample
eqEqualcolor = "red"
neqNot equalcategory ≠ "archived"
inContains (case-insensitive substring match)brand contains "app"
ninDoes not contain (case-insensitive substring match)brand does not contain "fake"
mthGreater thanprice > 100
lthLess thanprice < 50
exsExists (has value)Has description
nexsDoes not existNo image
patMatches 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 valuecurrency matches "s" (finds "usd")
sameHas the same value as at least one other product. conditionValue is ignoredproducts that share a price
same_partHas 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 wholeSKUs "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:

Try it live​

Run this method in the JS SDK sandbox. On your first visit, connect your Project URL and App Token, then open: