Skip to main content

getProductById

Get one product object by id.

Description

This method retrieves a single product object based on its identifier (id) from the API. It returns a Promise that resolves to a object for the product IProductsEntity.

Products.getProductById(

id*, langCode, isNormalized

);

Parameters schema

Schema

id(required): number
Product id
example: 12345

langCode: string
Language code. Default: "en_US"
example: "en_US"

isNormalized: boolean
If true, the product object will be normalized

Examples

Try it live

Run this method interactively in the JS SDK sandbox — connect your Project URL and App Token on first visit, then open:


Minimal example

const response = await Products.getProductById(1);

Example with attributes

const response = await Products.getProductById(1, 'en_US');

Example response

{
"id": 2954,
"attributeSetIdentifier": "products",
"localizeInfos": {
"title": "Box"
},
"statusLocalizeInfos": {
"title": "Sale"
},
"isVisible": true,
"statusIdentifier": "sale",
"position": 1,
"templateIdentifier": null,
"shortDescTemplateIdentifier": "product_preview",
"price": 51,
"additional": {
"prices": {
"min": 51,
"max": 150
}
},
"sku": null,
"isSync": true,
"categories": [
"catalog"
],
"paymentStages": null,
"rating": {},
"attributeValues": {
"product-name": {
"type": "string",
"value": "product-name",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"price": {
"type": "integer",
"value": 51,
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"currency_products": {
"type": "string",
"value": "usd",
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": false
},
"img": {
"type": "image",
"value": {
"size": 241636,
"filename": "files/project/product/2954/image/7e0a6a70-a23d-410f-8b6a-f8b4f7483244.png",
"contentType": "image/png",
"downloadLink": "https://your-project.oneentry.cloud/cloud-static/files/project/product/2954/image/7e0a6a70-a23d-410f-8b6a-f8b4f7483244.png"
},
"isIcon": false,
"position": 3,
"additionalFields": {},
"isProductPreview": false
}
},
"productPages": [
{
"id": 2847,
"pageId": 10,
"productId": 2954,
"positionId": 3190,
"categoryPath": "catalog"
}
],
"blocks": [
"product_block"
],
"moduleFormConfigs": [
{
"id": 12,
"formIdentifier": "review",
"moduleIdentifier": "catalog",
"isGlobal": false,
"isClosed": false,
"isModerate": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "catalog",
"isNested": true
}
],
"formDataCount": 428,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"2954": 428
},
"nestedEntityIdentifiers": [
"catalog"
],
"exceptionIds": []
}
],
"discountConfig": {}
}

Response schema

Schema: IProductsEntity

id: number
The unique identifier.
example: 12345

localizeInfos: ILocalizeInfo
The name of the products, taking into account localization.
example:

statusIdentifier: string | null
Product page status identifiers (may be null).
example: "in_stock"

statusLocalizeInfos: ILocalizeInfo
Localized status name for the product.
example: { "title": "Sale" }

attributeSetIdentifier: string | null
Set of attributes id.
example: "set_12345"

position: number
Item number (for sorting).
example: 1

price: number | null
The value of the product page price taken from the index.
example: 150.00

additional: object
Additional value from the index.
example: { prices: { min: 5 max: 150 } }

sku: string | null
Product SKU (Stock Keeping Unit), may be null.
example: "SKU_12345"

isSync: boolean
Indication of page indexing.
example: true

attributeValues: AttributeType
Array of attribute values from the index, represented.
example:

[
{
"id": "color",
"value": "red"
}
]

categories: string[]
Product categories.
example:

[
1,
2,
3
]

isVisible: boolean
A sign of page visibility.
example: true

moduleFormConfigs: Array<IFormConfig>
Module form configurations (optional).

rating: IRating
Rating data.

isPositionLocked: boolean
Sorting position lock indicator (optional).
example: false

relatedIds: number[]
Ids of related product pages.
example:

[
12345,
67890
]

paymentStages: unknown
Payment stages data (may be null).
example: null

discountConfig: Record<string, unknown>
Discount configuration object.
example:

templateIdentifier: string | null
User id of the linked template.
example: "template_12345"

shortDescTemplateIdentifier: string | null
User id of the linked template for a short description.
example: "short_desc_template_12345"

signedPrice: string
Price sign.

productPages: IProductPageRef[]
Array of product page references linking the product to its pages.
example:

[
{
"id": 16,
"pageId": 4,
"productId": 15,
"positionId": 244,
"categoryPath": "products"
}
]

productPages.id: number
Unique identifier of the product-to-page link record.
example: 16

productPages.pageId: number
Identifier of the page the product is linked to.
example: 4

productPages.productId: number
Identifier of the product.
example: 15

productPages.positionId: number
Sorting position identifier within the page.
example: 244

productPages.categoryPath: string
Category path of the page the product belongs to.
example: "products"

blocks: string[]
Array of block identifiers.
example:

[
"block_12345",
"block_67890"
]