Update the item image on search result popup with item record field value

In website setup added the field ‘custitem_large_item_00’ in the field sets, Type Ahead section. To get the field value in context.

Extend the view ItemsSearcher.Item.View to update the image.

The extension needed to be in shopping , myaccount, checkout section.

In js file added the below code

// To update the item image on itemsearch modal

_.extend(ItemsSearcherItemView.prototype, {

 getContext: _.wrap(ItemsSearcherItemView.prototype.getContext, function getContext(fn) {

  var context = fn.apply(this, _.toArray(arguments).slice(1));

  if (context.model) {

   var imageUrl = context.model.attributes.custitem_large_item_00;

   var altText = context.model.attributes.displayname;

   context.thumbnailUrl = imageUrl;

   context.thumbnailAltimagetext = altText;

  }

  return context;

 })

});

In theme ItemsSearcher/Templates/itemssearcher_item.tpl changed the variable  thumbnailUrl , thumbnailAltimagetext

Leave a comment

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