how to modify the search on website

To modify the search with out effecting the category search we can extend the the facet browser view and add code to child view .

 _.extend(FacetsBrowseView.prototype, {
                childViews: _.extend(FacetsBrowseView.prototype.childViews, {
                    'Facets.Items': function() {
                        try {
                            var self = this;
                            var display_option= _.find(this.itemsDisplayOptions, function(option) {
                                return option.id === self.translator.getOptionValue('display');
                            });
                            let collection = _.filter(this.model.get('items').models, item=> !!item.get("custitem_jj_makeitempriority"))
                            collection = _.sortBy(collection, item=> item.get("custitem_jj_makeitempriority"))  
                            return new FacetsItemsCollectionView({
                                application: this.application,
                                keywords: this.translator.getOptionValue('keywords'),
                                collection: this.model.options.data.q ? [...collection, ...(_.filter(this.model.get('items').models, item=> !item.get("custitem_jj_makeitempriority")))] : this.model.get('items').models,
                                viewsPerRow: parseInt(display_option.columns, 10),
                                cellViewTemplate: display_option.template
                            });
                        } catch (error) {
                            console.log('Error@Facets.Items',e);
                        }
                    }
                    
                }),
            });

Thank you

Leave a comment

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