Skip to main content

getProductsCountByPageId

Get the product count of a catalog page by page ID.

Description​

Counts the products on the catalog page with the given id, optionally filtered by the conditions in body, and resolves to an IProductsCount.

.getProductsCountByPageId( , );

Parameters schema​

Schema

id(required): number | string
Page ID.
example: 12345

body: any[]
Filter objects with search conditions. Default: [].
example:

[]

langCode: string
Language code. Default: "en_US". Must be one of the project's active languages — an inactive one answers 400 langCode must be one of the active languages. The count reflects the products visible in that language.
example:

[
{
"attributeMarker": "price",
"conditionMarker": "eq",
"conditionValue": 51
}
]

Examples​

Minimal example​

const response = await Products.getProductsCountByPageId(10);

Example with filters​

const response = await Products.getProductsCountByPageId(10, [
{ 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": 6,
"totalInCategoryWithNested": 6
}

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