Skip to main content

Product

In order to get product information you need to interact with the channel endpoint. You can choose to get:

  • All products from a specific channel
  • Individual product information by using the product id
  • Fetch all products in a specific currency.
  • Fetch the Return information for a product or for all products.
  • Fecht products with variants or without variants.

Products attributes:

This is the product attributes section of our eCommerce SDK documentation. As you build and integrate your eCommerce solutions, understanding the product attributes is crucial. These attributes provide essential details about the products in your store, ensuring seamless interaction and management. Below, you'll find a comprehensive list of attributes, their types, and descriptions to guide you through the integration process.

PropertyTypeDescription
idNumberUnique identifier for the product.
titleStringName or title of the product.
descriptionStringDetailed description of the product.
tagsStringTags associated with the product.
skuStringStock Keeping Unit code for the product.
quantityNumberAvailable quantity of the product in stock.
priceObjectPricing details of the product.
variantsArrayDifferent variations of the product (e.g., size, color).
barcodeStringBarcode associated with the product.
optionsArrayAdditional options related to the product.
categoriesArrayCategories the product belongs to.
imagesArrayArray of image URLs representing the product.
product_shippingArrayShipping options and details for the product.
supplierStringSupplier or manufacturer of the product.
imported_productObjectDetails if the product is imported or has special attributes.
referral_feeNumberFee for referring the product to others.
returnObjectReturn policy and details for the product.

Get all products

Retrieve an array of all the products to added to your channels.

Fetching all the products from the channel

const products = await sdk.channel.product.get({});
return products;

Parameters

ParametersTypeDescription
currencyStringCurrency code for filtering the products.

Fetching all the products with a specific currency

In this example, a function fetchAllProducts is defined to retrieve all products, but filtered by a specific currency. The getAll method on the sdk.products object is utilized, and it's invoked with a parameter 'NOK', which is a string representing the currency (Norwegian Krone in this case). This parameter instructs the getAll method to only retrieve products priced in the specified currency.

async function fetchAllProducts() => {
const currency = "NOK";
const products = await sdk.channel.product.get({ currency });
return products;
};

Fetching all the products without variants

async function fetchAllProducts(() => {
const products = await sdk.products.getAll('NOK', {returnVariants: false});
return products;
});

Fetching all the products with return policy

async function fetchAllProducts(() => {
const products = await sdk.products.getAll('NOK', {returnVariants: false, return: true});
return products;
});

Get products by ids

This function allows you to retrieve an array of products that have been added to your channel based on their IDs.

Function Signature

async function fetchAllProducts((productIds) => {
const fetchProductsByIds = await sdk.channel.product.getByIds({ product_ids: productIds });
return products;
});

As when fetching all the products, you may also add a custom currency:

async function fetchAllProducts((productIds, currency) => {
const fetchProductsByIds = await sdk.channel.product.getByIds({
product_ids: productIds,
currency
});
return products;
});

Parameters

ParametersTypeDescription
product_idsArrayAn array of product IDs you wish to retrieve.
currencyStringCurrency code for filtering the products.

Example 1: Fetching a Singel product

If you want to fetch a single product, simply pass an array with one product ID:

Example:
const productIds = [12345]; // Replace 12345 with your product ID

const products = fetchProductsByIds(productIds);
console.log(products);

Example 2: Fetching Multiple Products

To fetch multiple products, extend the array to include all the product IDs you're interested in:

const productIds = [12345, 67890]; // Replace with your product IDs

const products = fetchProductsByIds(productIds, "NOK");
console.log(products);

Additional Query Methods

Retrieve Products by Categories

Single Category

Retrieve all products associated with a specific category by providing the category ID as a string.

// Fetch products by a single category ID
fetchedProducts = await sdkClient.channel.product.getByCategoryId({
category_id: String((product.categories as Array)[0].id),
currency,
});
console.info('Products retrieved by category ID:', fetchedProducts);

Multiple Categories

Fetch products that belong to multiple categories by submitting the category IDs as an array.

// Fetch products by multiple category IDs
fetchedProducts = await sdkClient.channel.product.getByCategoryIds({
category_ids: [String((product.categories as Array)[0].id)],
currency,
});
console.info('Products retrieved by multiple category IDs:', fetchedProducts);

Retrieve Products Using Specific Parameters

You can fetch products based on specific attributes such as barcode, SKU, or product ID.

Simply invoke the getByParams method and provide the relevant parameters as shown in the examples below:

// Fetch product by barcode
fetchedProduct = await sdkClient.channel.product.getByParams({
barcode: String(product.barcode),
currency,
});
console.info('Products retrieved by barcode:', fetchedProduct);

// Fetch product by SKU
fetchedProduct = await sdkClient.channel.product.getByParams({
sku: String(product.sku),
currency,
});
console.info('Products retrieved by SKU:', fetchedProduct);

// Fetch product by product ID
fetchedProduct = await sdkClient.channel.product.getByParams({
product_id: product.id,
currency,
});
console.info('Products retrieved by product ID:', fetchedProduct);

Retrieve Products by Multiple SKUs

Retrieve a list of products by specifying multiple Stock Keeping Units (SKUs). This method allows you to query products using a comma-separated string of SKUs, and you can also specify the currency and desired image size for the returned product data.

// Fetch products by multiple SKUs
products = await sdkClient.channel.product.getBySkus({
skuStringList: `${products[0].sku},${products[1].sku}`,
image_size: 'large',
});
console.info('Products retrieved by SKUs:', products);