When the Cloudinary site cartridge has been integrated into your SFCC site, you may need to get the product's primary image url in any export feeds that is used by other services, such as recommendation services, SEO, review systems etc.
To get the product's primary image url, one will need to include the code in
int_cloudinary/cartridge/scripts/model/cloudinaryModel.js
And use the function getProductPrimaryImage:
/** * Get plp primary image along with srcset and sizes attributes. * * @param {string} productID - product ID * @param {string} viewType - media view type * @param {string} params - object holding optional params * * @returns {Object} object holding image URL and srcset attributes */
var getProductPrimaryImage = function (productID, viewType, params) {
...
return productPrimaryImg;
}
viewtype - can be passed in as null, otherwise, include the proper view type
params - is an object e.g.
{ pageType : 'plp' }
An object is returned from that method and you can get the products primary image url by referencing the key url, e.g.
myPrimaryProductImg.url
Note:
The returned url will be constructed based on the Cloudinary cartridge configurations mode (including operation mode, global transformations and any specific page type configs).
The returned url will be constructed based on the Cloudinary cartridge configurations mode (including operation mode, global transformations and any specific page type configs).
e.g. URL generated with cartridge configuration mode 1 and on the PLP page:
https://product-demos-res.cloudinary.com/image/list/$i_!sfcc-is-main:True!/fn_edge:join/f_auto,q_auto,dpr_2.0/w_300,c_scale/25503045M?_s=RAABAB0
https://product-demos-res.cloudinary.com/image/list/$i_!sfcc-is-main:True!/fn_edge:join/f_auto,q_auto,dpr_2.0/w_300,c_scale/25503045M?_s=RAABAB0
Comments
0 comments
Please sign in to leave a comment.