Skip to main content

ProductStatuses

Fetch product status labels ("New", "Sale", "Out of Stock") to badge and filter catalog items.

More information about product statuses in the OneEntry admin panel: https://doc.oneentry.cloud/docs/category/catalog (opens in a new tab)


Product statuses add filtering conditions for catalog items on top of attribute-based filters. They are custom labels such as "New Arrival", "Best Seller", "Sale" or "Out of Stock" that you use to badge, organize and filter products.

You define statuses in the OneEntry admin panel (Catalog > Product Statuses) and assign them to products there. This module fetches the statuses so you can filter products by them. The SDK is read-only: you can't create statuses through it.

Quickstart​

Initialize the module from defineOneEntry:


const { } = defineOneEntry(
, {
}
);

Fetch all statuses and read their fields:

// Fetch every product status, localized to English.
const statuses = await ProductStatuses.getProductStatuses("en_US");
if ('statusCode' in statuses) throw new Error(statuses.message);

statuses.forEach((status) => {
console.log(status.identifier, status.localizeInfos.title, status.isDefault);
});

// Or fetch a single status by its marker.
const sale = await ProductStatuses.getProductsByStatusMarker("sale", "en_US");
if ('statusCode' in sale) throw new Error(sale.message);
console.log(sale.localizeInfos.title); // "Sale"

Statuses rarely change, so they are good candidates for caching.

Status object​

A product status (IProductStatusEntity) is a custom label for products:

  • Status name (localizeInfos): localized display name (e.g. "New Arrival", "Sale")
  • Status marker (identifier): unique identifier used for filtering
  • Default flag (isDefault): whether this is the default status
  • Position (position): display order. You can reorder statuses by drag and drop in the admin panel, which changes position.

Workflow​

1. Create status in admin panel
(e.g., "New Arrival")
↓
2. Assign status to products
(Select products in admin)
↓
3. Fetch statuses via SDK
(ProductStatuses.getProductStatuses())
↓
4. Display status badges on products
(Render badges in product listings)
↓
5. Filter products by status marker
(Products.getProducts([{ statusMarker }], langCode))

Creating statuses​

Statuses are created in the admin panel (Catalog > Product Statuses), not through the SDK. Each status needs a Name (required) and a unique Marker (required).

Marker constraints:

  • Starts with a Latin letter; after that, Latin letters (a-z, A-Z), digits (0-9), underscores (_) and hyphens (-)
  • No spaces or special characters
  • Must be unique across all statuses

Use descriptive markers: new_arrival, not status1.

validateMarker(marker) returns true if the marker is free and false if a status already uses it. To confirm that a marker you hardcode exists, check for false, or call getProductsByStatusMarker(marker) and check for a 404.

Statuses on products​

A product references at most one status. The product object has statusIdentifier, the status marker or null:

const product = await Products.getProductById(123);
if ('statusCode' in product) throw new Error(product.message);
console.log(product.statusIdentifier); // "in_stock" - status marker, or null

To render a badge, fetch all statuses, map the markers to CSS classes or inline styles in your frontend, and apply them based on the product's statusIdentifier.

To filter products by status, use the Products module's getProducts(body, langCode, userQuery) and pass a statusMarker field inside the IFilterParams body array.

Statuses vs attributes​

FeatureProductStatusesAttributes
PurposeLabels/badges/filtersProduct properties
Examples"New", "Sale", "Featured"Color, Size, Material
Per productOne statusMany attributes
FilteringSimple (by status marker)Complex (ranges, values)
Use caseMarketing labelsProduct specifications

Use statuses for marketing labels and attributes for product properties.

Methods​

MethodDescriptionUse Case
getProductStatuses()Get all product statusesList all available statuses
getProductsByStatusMarker()Get a product status by markerFetch a status by identifier
validateMarker()Check whether a marker is freeCheck a marker before using it