Skip to content

Catalog ​

The catalog group reads what a shop sells: products, categories, collections and brands. Use it to build product cards, product pages, category and collection pages, brand pages and search.

Every call takes an optional request context last ({ headers, signal, orgId }). Amounts in an answer are plain numbers in the currency: 24900 is 24.900 kr., 179.9 is 179,90 €. Format one with formatPrice from @eldrajs/sdk/format. Only the minPrice and maxPrice filters you send are in minor units.

A signed-in business customer can get their own prices from listProducts, getProduct and listCollectionProducts. See Customer prices.

catalog.listProducts ​

Lists the products a shop sells online, one page at a time. Use it for the shop page, category pages, filters and "new in" rows.

ts
eldra.catalog.listProducts(options?, context?): Promise<EldraProductList>
NameTypeDefaultWhat it does
pagenumber—Page number, starting at 1.
pageSizenumber—Products per page. limit is an alias.
sortstring[]—Sort fields. Prefix with - for descending, as in ['-createdAt']. Accepted: createdAt, updatedAt, publishedAt, slug, category, totalVariants, translations.title, status, minPrice.
localestring—Language of titles and text, such as is-IS.
categoryIdstring[]—Products in any of these categories, or in any category beneath them. At most 50.
collectionIdstring[]—Products in any of these collections. At most 50.
brandIdstring[]—Products of any of these brands. At most 50.
optionstring[]—Option values as <optionKey>:<value>, such as colour:oat. Values of one key are OR'd; different keys are AND'd. At most 50.
extstring[]—Custom field values as <schemaApiId>.<fieldId>:<value>, such as care.fabric:wool. At most 10.
minPricenumber—Lowest variant price to include, in minor units, inclusive.
maxPricenumber—Highest variant price to include, in minor units, inclusive.
onSaleboolean—Only products with a variant marked down below its compare-at price.
availability'in_stock' | 'out_of_stock'—Only products a customer can buy now, or only those they cannot.
facetsbooleanfalseAdds a facets object with counts for building filters.
filterstring[]—Filter tokens as field:op:value, such as slug:in:hekla,lopi-classic.

The SDK sends each value of categoryId, collectionId, option, ext and filter as its own query parameter. Pass arrays; never join them with commas yourself.

Returns { data, meta, facets? }. data is a page of product cards, and can be null on an empty page.

FieldWhat it is
id, slug, titleIdentify and name the product. Link to /products/<slug>.
minPrice, maxPriceLowest and highest price a customer pays, after any automatic discount. Show minPrice as a "from" price when they differ.
compareAtPriceThe merchant's compare-at price. Present only while it is above the regular price.
priorPrice, discountLabelDescribe an automatic discount on the variant minPrice came from.
thumbnail{ url, altText?, width?, height?, assetId }. See Images.
brand{ id, name, slug, logo? }, when the product has one.
totalVariantsHow many variants the product has.
optionsOption swatches for the card, such as colours.
meta{ page, pageSize, total, totalPages, rows, hasNext, hasPrev }.

Errors worth handling

  • PRODUCT_FILTER_EXTENSION_INVALID (400): an ext token is not <schemaApiId>.<fieldId>:<value>.
  • PRODUCT_FILTER_EXTENSION_LIMIT (400): more than 10 ext tokens.
ts
import { formatPrice } from '@eldrajs/sdk/format';

const { data: sweaters, meta } = await eldra.catalog.listProducts({
  categoryId: [lopapeysurId],
  option: ['colour:oat', 'colour:charcoal'],
  maxPrice: 30000, // 30.000 kr.
  sort: ['minPrice'],
  pageSize: 24,
  locale: 'is-IS',
});

for (const sweater of sweaters ?? []) {
  console.log(sweater.title, formatPrice(sweater.minPrice, 'ISK', 'is-IS'));
}

TIP

Prices in the answer are plain numbers in the currency, and minPrice already includes automatic discounts. Announce a reduction only against priorPrice.

catalog.getProduct ​

Reads one product with its variants, options and media. Use it for a product page.

ts
eldra.catalog.getProduct(productIdOrSlug, options?, context?): Promise<EldraProductDetails>
NameTypeDefaultWhat it does
productIdOrSlugstring—The product's id or its slug.
localestring—Language of titles and text.
currencystringstore currencyPrices the variants in this selling currency, such as EUR. Needs gateway contract 6.19.0 or later.

Returns the product. categoryIds, options, variants and mediaByOptionValue are always present. variants lists only variants a customer can buy.

FieldWhat it is
id, slug, titleIdentify and name the product.
optionsEach option, such as size or colour: { id, key, kind, name, values }.
variantsEach variant: { id, sku, price, compareAtPrice?, priorPrice?, optionValues, media? }.
mediaLinksThe product's images.
mediaByOptionValueImages per option value, so picking a colour can switch the gallery.
brand{ id, name, slug, logo? }, when the product has one.
seo{ title?, description?, canonicalUrl?, noindex?, ogTitle?, ogDescription?, imageUrl? }.
extensionsCustom fields, keyed by CMS schema, then field. Absent when there are none.
requiresShipping, shipsAbroadWhether the product is shipped, and whether it can leave Iceland.

A product that is missing, not active or not sold online answers 404.

ts
const sweater = await eldra.catalog.getProduct('lopapeysa-hekla', { locale: 'is-IS' });

const size = sweater.options?.find((option) => option.key === 'size');
const cheapest = sweater.variants?.reduce((a, b) => (a.price <= b.price ? a : b));

console.log(
  sweater.title,
  size?.values?.map((value) => value.name)
);
console.log(formatPrice(cheapest!.price, 'ISK', 'is-IS')); // "24.900 kr."

Custom fields in extensions are typed once you generate types. See Generated types.

catalog.listCategories ​

Lists every active category in one flat list. Use it to build the category menu and breadcrumbs.

ts
eldra.catalog.listCategories(options?, context?): Promise<EldraCategory[]>
NameTypeDefaultWhat it does
localestring—Language of titles and descriptions.

Returns an array, never paged. It is [] when the shop has no categories.

FieldWhat it is
id, slug, titleIdentify and name the category.
parentIdIts nearest active parent. Absent for a top-level category.
description, seoText for the category page.

Every parentId names a category in the same list, so you can build the tree yourself.

ts
const categories = await eldra.catalog.listCategories({ locale: 'is-IS' });

const topLevel = categories.filter((category) => !category.parentId);
const childrenOf = (id: string) => categories.filter((category) => category.parentId === id);

TIP

Link a category as /categories/<path>, its slugs from the top down, such as /categories/peysur/lopapeysur. Eldra's emails link there.

catalog.listCollections ​

Lists the shop's active collections, one page at a time. Use it for a "shop by collection" page or a menu.

ts
eldra.catalog.listCollections(options?, context?): Promise<EldraCollectionList>
NameTypeDefaultWhat it does
pagenumber—Page number, starting at 1.
pageSizenumber—Collections per page. limit is an alias.
sortstring[]—Sort fields. Prefix with - for descending.
filterstring[]—Filter tokens as field:op:value.
localestring—Language of titles and descriptions.

Returns { data, meta }. data can be null on an empty page.

FieldWhat it is
id, slug, titleIdentify and name the collection. Link to /collections/<slug>.
image{ url, altText?, width?, height?, assetId }, when set.
productCountHow many products are in it.
description, seoText for the collection page.
ts
const { data: collections } = await eldra.catalog.listCollections({ locale: 'is-IS' });

catalog.getCollection ​

Reads one active collection by its slug. Use it for the header of a collection page.

ts
eldra.catalog.getCollection(slug, options?, context?): Promise<EldraCollection>
NameTypeDefaultWhat it does
slugstring—The collection's slug.
localestring—Language of the title and description.

Returns one collection, with the same fields as in listCollections, plus sortMode: how the merchant ordered its products.

ts
const collection = await eldra.catalog.getCollection('vetrarlinan', { locale: 'is-IS' });

catalog.listCollectionProducts ​

Lists the products in one collection, one page at a time. Use it for the product grid on a collection page.

ts
eldra.catalog.listCollectionProducts(slug, options?, context?): Promise<EldraProductList>

It takes the same options as listProducts, except collectionId. Two differ:

NameTypeDefaultWhat it does
slugstring—The collection's slug.
sortstring[]the collection's own orderAccepted: position, title, minPrice, createdAt. Prefix with - for descending.

Returns the same { data, meta, facets? } as listProducts. Only products a customer can see and buy are listed.

Errors worth handling: the same PRODUCT_FILTER_EXTENSION_INVALID and PRODUCT_FILTER_EXTENSION_LIMIT as listProducts.

ts
const [collection, products] = await Promise.all([
  eldra.catalog.getCollection('vetrarlinan', { locale: 'is-IS' }),
  eldra.catalog.listCollectionProducts('vetrarlinan', {
    availability: 'in_stock',
    facets: true,
    pageSize: 24,
    locale: 'is-IS',
  }),
]);

catalog.listBrands ​

Lists the shop's active brands, ordered by name. Use it for a brand index or a brand filter.

ts
eldra.catalog.listBrands(options?, context?): Promise<EldraBrand[]>
NameTypeDefaultWhat it does
localestring—Language of descriptions.

Returns an array, never paged. It is [] when the shop has no brands.

FieldWhat it is
id, slug, nameIdentify and name the brand.
logo{ url, altText?, width?, height?, assetId }, when set.
descriptionIn the requested locale, else the default one, else absent.
seoText for a brand page.
ts
const brands = await eldra.catalog.listBrands({ locale: 'is-IS' });

catalog.getBrand ​

Reads one active brand by its slug. Use it for a brand page, with listProducts({ brandId }) for its products.

ts
eldra.catalog.getBrand(slug, options?, context?): Promise<EldraBrand>
NameTypeDefaultWhat it does
slugstring—The brand's slug.
localestring—Language of the description.

Returns one brand, with the same fields as in listBrands.

Errors worth handling

  • CATALOG_BRAND_NOT_FOUND (404): the brand is missing or not active. Show your not-found page.
ts
import { isEldraError } from '@eldrajs/sdk';

try {
  const brand = await eldra.catalog.getBrand('istex', { locale: 'is-IS' });
  const { data: products } = await eldra.catalog.listProducts({ brandId: [brand.id] });
} catch (error) {
  if (isEldraError(error, 'CATALOG_BRAND_NOT_FOUND')) return notFound();
  throw error;
}

catalog.search ​

Searches the shop's public content: products, CMS entries and categories. Use it for a search box or a search results page.

ts
eldra.catalog.search(query, options?, context?): Promise<EldraSearchResponse>
NameTypeDefaultWhat it does
querystring—What the shopper typed.
types('PRODUCT' | 'CMS_ENTRY' | 'CATEGORY')[]allWhich kinds of result to return.
limitnumber—Most results to return.
localestring—Language to search in.

Returns { results, total }. results can be null when nothing matched.

FieldWhat it is
kindPRODUCT, CMS_ENTRY, CMS_SCHEMA or CATEGORY.
title, summary, snippetText to show for the result.
targetUrlWhere the result links to, when known.
sourceIdThe id of the product, entry or category found.
breadcrumbWhere the result sits, for display.
scoreHow well it matched.
ts
const { results, total } = await eldra.catalog.search('lopapeysa', {
  types: ['PRODUCT'],
  limit: 8,
  locale: 'is-IS',
});

WARNING

Search results always carry list prices, never a business customer's prices. Read prices for a signed-in customer from listProducts or getProduct.

Eldra