Get the thumbnail of parent categories of an item in PDP

Get the parent category details using the method getItemInfo() in the entry point file.

var item = pdp.getItemInfo();


Fetch the category model in the view file.
Pass the url of the parent category to the Category Model and get the thumbnail.

this.ParentCategories= item.commercecategory.categories;

_.each(this.ParentCategories, function(pc){
pc.url=pc.urls[0];
var categoriesFetch = new CategoriesModel().fetch({
data: {
fullurl: pc.urls[0]
}
}).done(function(result){
pc.thumbnail=result.thumbnailurl;
self.render();
});
});

Leave a comment

Your email address will not be published. Required fields are marked *