Entity Routes
Resolve URL paths to concrete storefront entities.
Method
Resolve
Use: entityRoutes.resolve(urlPart, options?).
| Parameter | Type | Required | Description |
|---|---|---|---|
urlPart | string | Required | URL path (e.g. /product/shoe-123). |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<EntityRouteResponse>.
Product entities use the Product detail shape. The SDK
places the resolved entity ID in entityId and omits it from entity.
Use products.get() for product pages and this method to resolve category,
CMS, and blog paths. Pass a full path to entityRoutes.resolve().
products.get() accepts a slug or product path and returns the product alone,
including taxonomy when the store assigned one. Product routes omit taxonomy.
Narrow the response by entityType before reading entity-specific fields:
const response = await client.entityRoutes.resolve('/category/shoes');
if (response.error) {
// Render the request error.
} else if (response.data.entityType === 'product_category') {
const route = response.data;
const { name, description, productsCount } = route.entity;
// Render the category information using route.entityId as its ID.
}EntityRouteResponse fields
| Field | Type | Required | Description |
|---|---|---|---|
entityType | 'product' | 'product_category' | 'cms_page' | 'blog_page' | 'unknown' | Required | Resolved entity type discriminator. |
entityId | number | Required | Resolved entity ID. |
url | string | Required | Resolved URL path. |
entity | Product | ProductCategory | CmsPage | BlogPage | Optional | Present when entityType is not unknown. |
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.entityRoutes.resolve('/product/sample-product').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.
EntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
ProductEntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
entityType | 'product' | Required |
entity | Product | Required |
ProductCategoryEntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
entityType | 'product_category' | Required |
entity | ProductCategory | Required |
CMSPageEntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
entityType | 'cms_page' | Required |
entity | CmsPage | Required |
BlogPageEntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
entityType | 'blog_page' | Required |
entity | BlogPage | Required |
UnknownEntityRoute
Source: src/types/entity-route.ts
| Field | Type | Required |
|---|---|---|
entityType | EntityType | Required |
entityId | number | Required |
url | string | Required |
entityType | 'unknown' | Required |
entity | never | Optional |
EntityRouteResponse
Source: src/types/entity-route.ts
Type: \| ProductEntityRoute \| ProductCategoryEntityRoute \| CMSPageEntityRoute \| BlogPageEntityRoute \| UnknownEntityRoute