Store Hugs Developers

Classifications

How the shop organises its products: its classifications (Category, Brand, Material…) and each one's terms, for your site's menus and filters.

Reach them through $storefront->taxonomies. A publishable or a secret key reads them.

List classifications

$storefront->taxonomies->list(): array

The shop's classifications in the order the merchant set in the panel, without their terms. Read a classification's terms with its slug.

Returns

A list of Taxonomy arrays, each:

FieldTypeDescription
[].idinteger
[].slugstringNames the classification in /api/v1/taxonomies/{taxonomy}/terms.
[].namestring or null
[].isTreebooleanIts terms have levels (a term under another).
[].isMultiplebooleanA product may have more than one of its terms.

Errors

StatusWhen
401invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404Not found, or the shop's plan has no Integration API.
429Rate limited.

Example

foreach ($storefront->taxonomies->list() as $taxonomy) {
    echo $taxonomy['slug'], ': ', $taxonomy['name'], PHP_EOL;
}

List a classification's terms

$storefront->taxonomies->terms(string $taxonomy): array

One classification's terms as a tree, each term's children under it. A classification without levels (isTree false) has no children. A term's id filters the product list as taxonomy.

Parameters

Parameter Type
$taxonomy string The classification's slug, from list().

Returns

A list of TaxonomyTerm arrays, each:

FieldTypeDescription
[].idintegerFilters the product list (taxonomy[]).
[].slugstring
[].namestring or null
[].childrenarray of TaxonomyTerm

Errors

StatusWhen
401invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404taxonomy_not_found, or the shop's plan has no Integration API.
429Rate limited.

Example

$brands = $storefront->taxonomies->terms('brand');

$page = $storefront->products->list(['taxonomy' => [$brands[0]['id']]]);