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 varians or without varians.

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.
subcategoriesArraySubcategories the product belongs to.
imagesArrayArray of image URLs representing the product.
productShippingArrayShipping options and details for the product.
supplierStringSupplier or manufacturer of the product.
importedProductObjectDetails if the product is imported or has special attributes.
referralFeeNumberFee 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.products.getAll();
return products;

Parameters

ParametersTypeDescription
CurrencyStringAn array of product IDs you wish to retrieve.

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 products = await sdk.products.getAll('NOK');
return products;
};

Response:

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 fetchProductsByIds(ids: number[]): Promise<Product[]>

Parameters

ParametersTypeDescription
idsArrayAn array of product IDs you wish to retrieve.

Exemple 1: Fetshing 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 = await 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 = await fetchProductsByIds(productIds);
console.log(products);