Eg for addToViewContextDefinition & the components PLP, PDP, Cart,

mountToApp: function mountToApp(container) {

                var layout = container.getComponent(‘Layout’);

                var plp = container.getComponent(‘PLP’);

//EXTESNION TO FETCH THE ITEM NAME FROM ‘storedescription’ AND DISPLAY IN PLP PAGE.

                if (plp) {

                    plp.addToViewContextDefinition(‘Facets.ItemCell.View’, ‘name’, ‘string’, function name(context) {

                        var model = _.find(plp.getItemsInfo(), function(item) {

                            return item.internalid == context.itemId

                        });

                        return model.storedescriptio

   });

                    plp.addToViewContextDefinition(‘Facets.ItemCell.View’, ‘isPromotionItem’, ‘string’, function isPromotionItem(context) {

                        var model = _.find(plp.getItemsInfo(), function(item) {

                            return item.internalid == context.itemId

                        });

                        return model.custitem_on_promotion

                    });

                }

                var pdp = container.getComponent(‘PDP’);

//EXTESNION TO FETCH THE ITEM NAME FROM ‘storedescription’ AND DISPLAY IN PDP PAGE.

                if (pdp) {

                    pdp.addToViewContextDefinition(‘ProductDetails.Full.View’, ‘pageHeader’, ‘string’, function pageHeader(context) {

                        var model = _.find(pdp.getItemInfo(), function(item) {

                            return item.internalid == context.itemId

                        });

                        return context.model.item.storedescription;

                    });

                }

//EXTESNION TO FETCH THE ITEM NAME FROM ‘storedescription’ AND DISPLAY IN PDP PAGE.

                var cart = container.getComponent(‘Cart’);

                if (cart) {

                    cart.addToViewContextDefinition(‘Cart.Lines.View’, ‘itemname’, ‘string’, function cartName(context) {

                        return context.item.storedescription;

                    });

Leave a comment

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