Products
Product lookup, filtered listing, and cross-entity search.
Use this module for product grids, product pages, and product discovery.
| Use case | Method | Response data |
|---|---|---|
| Product grid | products.list(filters?) | PaginatedResponse<ProductListItem> |
| Product detail page | products.get(slugOrPath) | Product |
| Cross-entity search | products.search(query, filters?) | SearchResponse |
Methods
Get
Use: products.get(slugOrPath, options?).
| Parameter | Type | Required | Description |
|---|---|---|---|
slugOrPath | string | Required | Product slug (shoe-123) or full path (/product/shoe-123). |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<Product>.
Accepts a slug or full product path and returns the detail product.
All images and attributes (including description and SEO) are available here.
themeConfig is absent when the product has no custom page. Images, variants,
and categories preserve the API's null versus [] values. taxonomy is
present when the store assigned a taxonomy category or specification metafields
to the product; see Taxonomy and specification table.
List
Use: products.list(filters?, options?).
| Field | Type | Required | Description |
|---|---|---|---|
filters.page | number | Optional | Page number. |
filters.pageSize | number | Optional | Items per page; capped at 100 by the API. |
filters.sort | 'newest' | 'best-selling' | 'availability' | 'discount' | '!price' | 'price' | Optional | Sort strategy. |
filters.categories | number | number[] | Optional | Category filter(s). |
filters.priceMin | number | Optional | Minimum price. |
filters.priceMax | number | Optional | Maximum price. |
filters.availableOnly | boolean | Optional | Stock filter behavior. |
filters.discountedOnly | boolean | Optional | Discounted products only. |
filters.pinnedIds | number[] | Optional | Pin products on top. |
filters.similarTo | number | Optional | Similar-to product ID. |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<PaginatedResponse<ProductListItem>>.
items contains ProductListItem
objects intended for product cards. Fetch products.get() for categories,
custom page configuration, description and SEO attributes, and variant SKUs.
Search
Use: products.search(query, filters?, options?).
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Required | Search text. |
filters | ProductFilters | Optional | Search uses page and pageSize. Other product-list filters are not sent by this method. |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<SearchResponse>.
Product hits use the same
ProductListItem shape as lists, with a two-image default. See
Search for the other result groups.
Response key fields
ProductListItem
| Field | Type | Description |
|---|---|---|
id, name, url | number, string, string | Product identity and resolved storefront URL. |
productType, enabled | string, boolean | Product type and enabled status. |
imageCount | number | Total product images, including images outside the returned collection. |
images | ProductImage[] | null | Images for the card, including variant-referenced images. |
variants | ProductListVariant[] | null | Pricing, stock, order constraints, and variant attributes. |
attributes | ProductAttribute[] | Optional card attributes. |
dynamicFormId, eventEntityId | number | Optional form and event identifiers. |
Card attributes exclude description, metaTitle, metaDescription,
metaKeywords, focusKeyphrase, redirect, canonical, noindex, and id.
These attributes are available on the detail product.
Product
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Required | Product name. |
url | string | Required | Product URL path. |
enabled | boolean | Required | Enabled status. |
variants | ProductVariant[] | null | Required | Detail variants, including sku when present. |
images | ProductImage[] | null | Required | All images: id, alt, url, width, height. |
categories | ProductBreadcrumbCategory[] | null | Required | Breadcrumb categories with only id, name, url. |
attributes | ProductAttribute[] | Optional | Additional attributes. |
taxonomy | ProductTaxonomy | Optional | Taxonomy category path and specification table rows. |
Images and optional fields
List images default to the first two images plus any images referenced by
variants, in the original order. A list item can return more than two images.
Use imageCount for the total number of product images. Details return all
images; count their images collection when it is present.
products.list() always uses this default; ProductFilters has no image-limit
option. The server returns at most 100 items per page, regardless of pageSize.
import type { ProductListItem } from '@sazito/client-sdk';
function cardImages(product: ProductListItem) {
const images = product.images ?? [];
return {
coverUrl: images[0]?.url,
totalImages: product.imageCount,
remainingImages: Math.max(0, product.imageCount - images.length),
};
}The array fallback above is for presentation. The SDK preserves null and []
as returned by the API. themeConfig is absent when a detail product has no
custom page; use optional access when reading it.
Product images expose id, alt, url, width, and height. Use url to
display an image and positive dimensions to calculate an aspect ratio.
Variants, pricing, and categories
Use variant.price for the final price, including gold-pricing adjustments.
originalPrice is the raw price when present. Gold component breakdowns,
shipping weight, download links, and timestamps are not part of storefront
variants. Product timestamps and tags are not part of storefront products.
A variant contains its own attributes and identifiers. Read the product's
name and URL from the surrounding Product or ProductListItem.
Detail categories provide id, name, and url for breadcrumbs. To get a
category's description or product count, resolve its URL through
Entity Routes.
Taxonomy and specification table
product.taxonomy carries the store's taxonomy assignment for the product: the
taxonomy category path and the specification table ("ویژگیها") shown on
product pages. It is absent when the product has neither a taxonomy category
nor specification metafields. Product lists, search hits, and entity routes
never include it.
| Field | Type | Description |
|---|---|---|
category | ProductTaxonomyTerm | null | Assigned taxonomy category; null when uncategorized. |
breadcrumb | ProductTaxonomyTerm[] | Category ancestors followed by the category itself, root first. |
categoryPath | string | Breadcrumb names joined with >; empty when there is no category. |
metafields | ProductTaxonomyMetafield[] | Specification rows with attribute and value identifiers. |
features | ProductTaxonomyFeature[] | Table rows: label is the attribute name and value joins the value names. |
Taxonomy terms expose a string id, a Persian name, and enName when the
taxonomy provides an English name. Taxonomy identifiers are separate from
storefront category IDs, and breadcrumb entries carry no storefront URL.
features skips metafields without an attribute name or without values, joins
several values with ، , and drops duplicate rows. Read metafields when you
need the identifiers, for example to build filters or structured data.
import type { Product } from '@sazito/client-sdk';
function specificationTable(product: Product) {
const taxonomy = product.taxonomy;
if (!taxonomy || taxonomy.features.length === 0) return null;
return {
categoryPath: taxonomy.categoryPath,
rows: taxonomy.features.map(({ label, value }) => ({ label, value })),
};
}Dynamic forms
Fetch the form definition when rendering a product form. Use the selected
variant's dynamicFormId, falling back to the product's ID when absent:
import { createSazitoClient } from '@sazito/client-sdk';
const client = createSazitoClient({ domain: 'mystore.sazito.com' });
async function loadProductForm(slug: string, variantId: number) {
const response = await client.products.get(slug);
if (response.error) return response;
const product = response.data;
const variant = product.variants?.find((item) => item.id === variantId);
const formId = variant?.dynamicFormId ?? product.dynamicFormId;
if (formId === undefined || formId <= 0) return null;
return client.dynamicForms.getForm(formId);
}
const formResponse = await loadProductForm('shoe-123', 12001);
// null means no form; otherwise handle formResponse.data or formResponse.error.See Dynamic Forms for form fields and uploads.
SDK response fields
Product lists return items, total, page, pageSize, and totalPages
inside data.
products.get() returns the detail product as data, including variant SKUs
and taxonomy when present. Use the exported SDK types and camelCase field names when
rendering product data.
Attribute values and colors
ProductAttribute.value is either a display string or a rich
ProductAttributeValueObject. For color attributes, fieldType is usually
'color' and extra contains the color payload, commonly a hex value such as
'#ff0000'. The same normalized attribute shape is used by cart, invoice,
order, and checkout responses.
Import these types directly from the package in your application:
import type {
Product,
ProductListItem,
ProductVariant,
ProductTaxonomy,
ProductAttribute,
ProductAttributeValueObject
} from '@sazito/client-sdk';For the full list of SDK types, see TypeScript types.
Known errors
| Type | When it happens |
|---|---|
api | Product not found or rejected by the API. |
network | Connectivity/timeout issues. |
Examples
// app/lib/sazito-client.ts
import { createSazitoClient } from '@sazito/client-sdk';
export const sazito = createSazitoClient({
domain: process.env.NEXT_PUBLIC_SAZITO_DOMAIN!,
});// app/[lang]/(home)/page.tsx
'use client';
import { useEffect, useState } from 'react';
import { sazito } from '@/app/lib/sazito-client';
export default function Example() {
const [data, setData] = useState<any>(null);
useEffect(() => {
sazito.products.list({ page: 1, pageSize: 12 }).then((res) => setData(res.data ?? null));
}, []);
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}Type Details
The following tables are generated from SDK TypeScript types and include nested object fields.
ProductFilters
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
page | number | Optional |
pageSize | number | Optional |
sort | ProductSort | Optional |
categories | number | number[] | Optional |
priceMin | number | Optional |
priceMax | number | Optional |
availableOnly | boolean | Optional |
discountedOnly | boolean | Optional |
pinnedIds | number[] | Optional |
similarTo | number | Optional |
ProductListItem
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
name | string | Required |
url | string | Required |
enabled | boolean | Required |
productType | string | Required |
dynamicFormId | number | Optional |
eventEntityId | number | Optional |
attributes | ProductAttribute[] | Optional |
imageCount | number | Required |
images | ProductImage[] | null | Required |
variants | ProductListVariant[] | null | Required |
ProductListVariant
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
enabled | boolean | Required |
price | number | Required |
originalPrice | number | Optional |
stockQuantity | number | Required |
isStockManaged | boolean | Required |
attributes | ProductAttribute[] | Required |
hasMaxOrder | boolean | Required |
maxOrderQuantity | number | Required |
minOrderQuantity | number | Required |
dynamicFormId | number | Optional |
sortIndex | number | Required |
imageId | number | Optional |
Product
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Optional |
name | string | Required |
url | string | Required |
enabled | boolean | Required |
productType | string | Required |
themeConfig | JsonObject | Optional |
dynamicFormId | number | Optional |
eventEntityId | number | Optional |
attributes | ProductAttribute[] | Optional |
images | ProductImage[] | null | Required |
variants | ProductVariant[] | null | Required |
categories | ProductBreadcrumbCategory[] | null | Required |
taxonomy | ProductTaxonomy | Optional |
ProductVariant
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
enabled | boolean | Required |
price | number | Required |
originalPrice | number | Optional |
stockQuantity | number | Required |
isStockManaged | boolean | Required |
attributes | ProductAttribute[] | Required |
hasMaxOrder | boolean | Required |
maxOrderQuantity | number | Required |
minOrderQuantity | number | Required |
dynamicFormId | number | Optional |
sortIndex | number | Required |
imageId | number | Optional |
sku | string | Optional |
ProductBreadcrumbCategory
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
name | string | Required |
url | string | Required |
ProductTaxonomy
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
category | ProductTaxonomyTerm | null | Required |
breadcrumb | ProductTaxonomyTerm[] | Required |
categoryPath | string | Required |
metafields | ProductTaxonomyMetafield[] | Required |
features | ProductTaxonomyFeature[] | Required |
ProductTaxonomyTerm
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | string | Required |
name | string | Required |
enName | string | Optional |
ProductTaxonomyMetafield
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
attribute | ProductTaxonomyTerm | Required |
values | ProductTaxonomyTerm[] | Required |
ProductTaxonomyFeature
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
label | string | Required |
value | string | Required |
ProductCategory
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Optional |
name | string | Required |
url | string | Required |
enabled | boolean | Optional |
description | string | Optional |
productsCount | number | Optional |
themeConfig | JsonObject | Optional |
attributes | ProductAttribute[] | Optional |
createdAt | string | Optional |
updatedAt | string | Optional |
ProductAttribute
Source: src/types/common.ts
| Field | Type | Required |
|---|---|---|
name | string | Required |
attributeType | string | Optional |
type | string | Optional |
value | string | ProductAttributeValueObject | Required |
ProductAttributeValueObject
Source: src/types/common.ts
| Field | Type | Required |
|---|---|---|
value | string | Required |
extra | string | Optional |
fieldType | string | Optional |
ProductImage
Source: src/types/product.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
alt | string | Optional |
url | string | Required |
width | number | Optional |
height | number | Optional |
SearchResponse
Source: src/types/search.ts
| Field | Type | Required |
|---|---|---|
products | { items: ProductListItem[]; total: number; page: number; pageSize: number; } | Required |
products.items | ProductListItem[] | Required |
products.total | number | Required |
products.page | number | Required |
products.pageSize | number | Required |
blogPages | { items: BlogPage[]; total: number; page: number; pageSize: number; } | Required |
blogPages.items | BlogPage[] | Required |
blogPages.total | number | Required |
blogPages.page | number | Required |
blogPages.pageSize | number | Required |
cmsPages | { items: CmsPage[]; total: number; page: number; pageSize: number; } | Required |
cmsPages.items | CmsPage[] | Required |
cmsPages.total | number | Required |
cmsPages.page | number | Required |
cmsPages.pageSize | number | Required |
productCategories | { items: ProductCategory[]; total: number; page: number; pageSize: number; } | Required |
productCategories.items | ProductCategory[] | Required |
productCategories.total | number | Required |
productCategories.page | number | Required |
productCategories.pageSize | number | Required |