Skip to main content

getProductsCount

Get the count of all products with optional filters.

Description

This method retrieves the total count of products based on the provided filter parameters (body). It returns a Promise that resolves to an IProductsCount object containing various counts of products.

Products.getProductsCount( body );

Parameters schema

Schema

body(required): any[]
Body parameters for filter. Deault: []
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();
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
eqEqualstatusId = 1 (active only)
neqNot equalcategory ≠ "archived"
inContains (one of)category in ["electronics", "books"]
ninNot containsbrand not in ["fake_brand"]
mthMore thanprice > 100
lthLess thanprice < 50
exsExists (has value)Has description
nexsDoes not existNo image

conditionValue: The value to compare against.

Example response

{
"totalAll": 3,
"totalInCategory": 0,
"totalInCategoryWithNested": 0
}

Response schema

Schema: IProductsCount

totalAll: number
The total number of products found.
example: 100

totalInCategory: number
The total number of products found in category.
example: 50

totalInCategoryWithNested: number
The total number of products found in nested category.
example: 10