Skip to content

Product Selectors

Retrieves a specific product by its ID. It returns null if no product is found.

import { getProductById } from '@shopgate/engage/product';

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductById } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string) required: The product ID to search for.

(Object|null): Returns the product data object from the store. If no product is found, it returns null.

Products will have the shape of entities from the getProduct pipeline response.


Retrieves the product data for the passed productId from the store.

import { getProduct } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProduct } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product data. If no product is found, it returns null.

Products will have the shape of entities from the getProduct pipeline response.


Retrieves the name of a product from the product data in the store.

import { getProductName } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductName } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The product name. If no product is found, it returns null.


Retrieves product rating data from the product data in the store.

import { getProductRating } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductRating } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The rating data. If no product is found, it returns null.


Retrieves the product manufacturer from the product data in the store.

import { getProductManufacturer } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductManufacturer } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The manufacturer. If no product is found, it returns null.


Retrieves the product stock information from the product data in the store.

import { getProductStock } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductStock } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The stock information. If no product is found, it returns null.


Retrieves the availability information from the product data in the store.

import { getProductAvailability } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductAvailability } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The stock information. If no product is found, it returns null.


Retrieves the product flags from the product data in the store.

import { getProductFlags } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductFlags } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product flags. If no product is found, it returns null.


Retrieves the currency code from the product data in the store.

import { getProductCurrency } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductCurrency } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The currency code (ISO 4217 alphabetic code). If no product is found, it returns null.


Retrieves the unit price from the product data in the store.

import { getProductUnitPrice } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductUnitPrice } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(number|null): The unit price (float value). If no product is found, it returns null.


Retrieves whether a product has variants from the product data in the store.

import { hasProductVariants } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { hasProductVariants } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether the product has variants.


Retrieves whether a product is a base product (not a variant) from the product data in the store.

import { isBaseProduct } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { isBaseProduct } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether the product is a base product.


Retrieves a product ID of the base product from the product data in the store.

import { getBaseProductId } from '@shopgate/pwa-common-commerce/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { isBaseProduct } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The current base product ID. If no ID is determined, it returns null.


Retrieves the appropriate base product from the product data in the store - independent if the productId already references the base product.

import { getBaseProduct } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getBaseProduct } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.

(Object|null): The base product data. If no base product is found, it returns null.


Retrieves whether the base product has variants from the product data in the store.

import { hasBaseProductVariants } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { hasBaseProductVariants } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.

(boolean): Whether the base product has variants.


Retrieves the product metadata from the product data in the store.

import { getProductMetadata } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductMetadata } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product metadata. If no product is found, it returns null.


Retrieves the base product metadata from the product data in the store.

import { getBaseProductMetadata } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getBaseProductMetadata } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product metadata. If no product is found, it returns null.


Retrieves the shipping data from the product data in the store.

import { getProductShipping } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductShipping } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product shipping data. If no product or shipping data is found, it returns null.

{
currency: 'EUR',
price: 5.99
}

Retrieves the properties of a product from the product data in the store.

import { getProductProperties } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductProperties } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product properties. If no product or properties are found, it returns null.

[{
label: 'SKU',
value: '0123456789012'
}, {
label: 'Weight',
value: '150g'
}]

Retrieves the product description from the product data in the store.

import { getProductDescription } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductDescription } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The product description (might contain HTML markup). If no product or description is found, it returns null.


Retrieves the images for a product from the product data in the store. If the props contain a variant ID, and the related product does not have images, the selector attempts to choose images from its base product.

import { getProductImages } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductImages } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.
    • formats (Array<Object>): The desired formats of the returned images (need the be requested via the fetchProductImages action).

(Array|null): The product images. If no product or images are found, it returns null.

const props = {
productId: 'abc123',
formats: [{
width: 440, height: 440,
}, {
width: 1024, height: 1024,
}]
};
const images = getProductImages(state, props);
// Selector result
[{
width: 440,
height: 440,
sources: [
'https://images.expample.com/image',
'https://images.expample.com/image'
]
}, {
width: 1024,
height: 1024,
sources: [
'https://images.expample.com/image',
'https://images.expample.com/image'
]
}]

Retrieves the product variant data from the product data in the store.

import { getProductVariants } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductVariants } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(Object|null): The product variant data. If no product or variants are found, it returns null.


Retrieves whether a product is orderable from the product data in the store.

import { isProductOrderable } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { isProductOrderable } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether the product is orderable.


Retrieves the product ID of a variant product from the product data in the store. When none of the productIds from the props reference a variant product, the selector returns null.

import { getVariantId } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getVariantId } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(string|null): The product description. If no product or description is found, it returns null.


Retrieves an availability object for a passed set of variant characteristics from the product data in the store.

import { getVariantAvailabilityByCharacteristics } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getVariantAvailabilityByCharacteristics } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • characteristics (Array) required: The set characteristics.

(Object|null): The availability information. If no product is found, it returns null.


Retrieves the generated result hash for a category ID or search phrase.

import { getResultHash } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getResultHash } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • categoryId (string) : The category ID to use.
    • searchPhrase (string) : The search phrase to use.

(string|null): The result hash. If neither category ID nor search phrase is set, it returns null.


Retrieves a result set by a generated result hash from the product data in the store,

import { getResultByHash } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getResultByHash } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • categoryId (string) : The category ID to use.
    • searchPhrase (string) : The search phrase to use.

(Object|null): The result set. If neither category ID nor search phrase is set or no results are found, it returns null.


Retrieves a collection of product data based on either a category ID or a search phrase from the product data in the store.

import { getProductsResult } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductsResult } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • categoryId (string) : The category ID to use.
    • searchPhrase (string) : The search phrase to use.

(Object): The result set containing products, totalProductCount, sort and hash. If no products are found for the given category ID or search phrase, it returns the result set with an empty array of products.


Retrieves a product options from the product data in the store and transforms it to the correct data structure which can be used to render option pickers.

import { getProductOptions } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductOptions } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): A product ID to use.
    • variantId (string): A variant ID to use. If variant ID is sent, the product ID will be ignored.
    • currentOptions (Array): The currently set product options.

(Array): The product options.

const props = {
productId: 'abc123',
currentOptions: {
'1': '1', // {optionId}: {optionValueId}
'6': '21'
}
};
const options = getProductOptions(state, props)
// Selector result
[
{
id: '1',
label: 'Option 1',
type: 'select',
value: '1', // Selected optionValueId of "Option 1"
items: [
{
label: 'Option Value 1-1',
currency: 'EUR',
value: '1', // optionValueId
price: 1.4, // Product price modifier of this option value
priceDifference: 0.5 // Price difference compared to the currently visible price
},
{
label: 'Option Value 1-2',
currency: 'EUR',
value: '2',
price: 0,
priceDifference: -1
}
]
},
{
id: '6',
label: 'Option 2',
type: 'select',
value: '21',
items: [
{
label: 'Option Value 2-1',
currency: 'EUR',
value: '21',
price: 1,
priceDifference: 0
}
]
}
]

Retrieves whether a product has options from the product data in the store.

import { hasProductOptions } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { hasProductOptions } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether the product has options.


Checks if all product options for a product are set.

import { areProductOptionsSet } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { areProductOptionsSet } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether all options are set.


Retrieves whether the products of the product page are loading. Depending on the configuration of the base product, it also checks if the loading process of a selected variant is currently ongoing.

import { isProductPageLoading } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { isProductPageLoading } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(boolean): Whether the products of the product page are loading.


Retrieves the additional price for a product based on the selected options.

import { getProductPriceAddition } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductPriceAddition } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • options (Array) required: The selected options.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(number): The additional product price.


Retrieves the total product price by calculating all additional product option costs.

import { getProductTotalPrice } from '@shopgate/engage/product'

Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7: import { getProductTotalPrice } from '@shopgate/pwa-common-commerce/product'

  • state (Object) required: The application state.
  • props (Object) required: An object containing props.
    • options (Array) required: The selected options.
    • productId (string): The product ID to search for.
    • variantId (string): The variant ID to search for.

(number): The calculated total product price.