Site Specific Extension For PLP Page

Jira Code: OTG-28

In SCA, item name in the PLP page is fetching from storedisplayname2 or display name fields from item record. In order to display the item name from a new field, we can use the extension below.


 define(
    'JJ.SiteSpecific_Extension.SiteSpecificExtension', [
        'JJ.SiteSpecific_Extension.SiteSpecificExtension.View'
    ],
    function(
        SiteSpecificExtensionView
    ) {
        'use strict';

        return {
            mountToApp: function mountToApp(container) {
                // using the 'Layout' component we add a new child view inside the 'Header' existing view 
                // (there will be a DOM element with the HTML attribute data-view="Header.Logo")
                // more documentation of the Extensibility API in
                // https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html

                /** @type {LayoutComponent} */
                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.storedescription

                    });
                }


            }
        };
    });

Leave a comment

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