Loading
Get Started with B2C Commerce
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Promotion Refinement Code Changes

          Promotion Refinement Code Changes

          The following two files require necessary changes to display promotion refinements.

          • cartridge/scripts/models/SearchModel.js
            SearchModel.initializeProductSearchModel = function (httpParameterMap) {
                var productSearchModel = this.initializeSearchModel(new ProductSearchModel(), httpParameterMap);
             
                productSearchModel.setRecursiveCategorySearch(true);
             
                if (httpParameterMap.pid.submitted) {
                    productSearchModel.setProductID(httpParameterMap.pid.value);
                }
             
                if (httpParameterMap.pmin.submitted) {
                    productSearchModel.setPriceMin(httpParameterMap.pmin.doubleValue);
                }
             
                if (httpParameterMap.pmax.submitted) {
                    productSearchModel.setPriceMax(httpParameterMap.pmax.doubleValue);
                }
                 
                // NEW CODE FOR PROMOTION REFINEMENT - START!!!!
                if (httpParameterMap.pmid.submitted) {
                    productSearchModel.setPromotionID(httpParameterMap.pmid);
                }
                // NEW CODE FOR PROMOTION REFINEMENT - END!!!!
             
                var sortingRule = httpParameterMap.srule.submitted ? CatalogMgr.getSortingRule(httpParameterMap.srule.value) : null;
                if (sortingRule) {
                    productSearchModel.setSortingRule(sortingRule);
                }
             
                // only add category to search model if the category is online
                if (httpParameterMap.cgid.submitted) {
                    var category = CatalogMgr.getCategory(httpParameterMap.cgid.value);
                    if (category && category.isOnline() && productSearchModel) {
                        productSearchModel.setCategoryID(category.getID());
                    }
             
                }
             
                return productSearchModel;
          • cartridge/templates/default/search/components/productsearchrefinebar.isml
            Note
            Note

            The change must be added along side an existing refinement.

            <div class="refinement-promotion">
                    <iscomment>PROMOTION REFINEMENTS (NEW)</iscomment>
                    <isif condition="${RefinementDefinition.isPromotionRefinement()}">
            
                        <h3 class="toggle">
                            <i class="fa fa-chevron-circle-down"></i>
                            <isprint value="${RefinementDefinition.getDisplayName()}"/>
                        </h3>
            
            
                        <isif condition="${pdict.ProductSearchResult.isRefinedByPromotion()}">
                            <div class="clear-refinement">
                                <a title="${Resource.msg('search.productsearchrefinebar.showallopt','search',null)}" href="${pdict.ProductSearchResult.urlRelaxPromotion('Search-Show')}">${Resource.msg('searchrefinebar.clearselection','search',null)}</a>
                            </div>
                        </isif>
            
                        <ul <isif condition="${Refinements.getAllRefinementValues(RefinementDefinition).size() > RefinementDefinition.cutoffThreshold}">class="scrollable"</isif>>
                        <isloop items="${Refinements.getAllRefinementValues(RefinementDefinition)}" var="RefinementValue">
                            <isif condition="${pdict.ProductSearchResult.isRefinedByPromotion(RefinementValue.value)}">
                                <li class="selected">
                                    <a class="refinement-link" href="${StringHelpers.unsanitizeOR(pdict.ProductSearchResult.urlRelaxPromotion('Search-Show'))}" title="${Resource.msg('search.productsearchrefinebar.clickrefine','search',null)}${RefinementValue.getDisplayValue()}">
                                        <i class="fa fa-check-square-o fa-lg"></i>
                                        <isprint value="${RefinementValue.getDisplayValue()}" encoding="off"/> (<isprint value="${RefinementValue.getHitCount()}" encoding="off"/>)
                                    </a>
                                </li>
                            <iselse/>
                                <li>
                                    <a class="refinement-link" href="${StringHelpers.unsanitizeOR(pdict.ProductSearchResult.urlRefinePromotion('Search-Show',RefinementValue.getValue()))}" title="${Resource.msg('search.productsearchrefinebar.clickrefine','search',null)}${RefinementValue.getDisplayValue()}">
                                        <i class="fa fa-square-o fa-lg"></i>
                                        <isprint value="${RefinementValue.getDisplayValue()}" encoding="off"/> (<isprint value="${RefinementValue.getHitCount()}" encoding="off"/>)
                                    </a>
                                </li>
                            </isif>
                        </isloop>
                        </ul>
                    </isif>
                    </div>
           
          Loading
          Salesforce Help | Article