In a multi domain website , we have to filter the items based on the domain.
We have already filter the category based on the domain , so the in the PLP, PDP page on the webstore now items are obtaining based on the domain
But in case of the search in the webstore the same items are available in all over the website.
In order to resolve the issue we have to extend the search section view to apply condition on the item collection that is going to be displayed based on the search keyword. we will filter the search query result again to display the items in the result based on the domain
The code to restrict the item that do not belong to the current domain in the search bar drop down section
_.extend(ItemsSearcherItemView.prototype, {
initialize: _.wrap(ItemsSearcherItemView.prototype.initialize, function (fn) {
fn.apply(this, _.toArray(arguments).slice(1));
if(!!this.model){
if(this.model.get('domain')=="82"){
this.model.set("showItem",true);
}
}
console.log("sruthy this", this);
}),

The code to restrict the item that do not belong to the current domain in the facet browse section
_.extend(FacetsBrowseView.prototype, {
childViews: _.extend(FacetsBrowseView.prototype.childViews, {
'Facets.Items': function () {
var self = this,
display_option = _.find(this.itemsDisplayOptions, function (option) {
return option.id === self.translator.getOptionValue('display');
});
console.log("ghghg this", this);
var keyword = this.translator.getOptionValue('keywords');
console.log("keyword", keyword);
if (!!keyword) {
var mycollection = _.isEmpty(this.model.get('items')) ? {} : this.model.get('items');
console.log("mycollection", mycollection);
if (!!mycollection) {
var filteredItems = mycollection.filter(function (models) {
return models.get('domain') === "82";
});
console.log("filteredItems", filteredItems);
var abc = new BackboneCollectionView({
childTemplate: display_option.template,
childView: FacetsItemCellView,
childViewOptions: {
application: this.application
},
viewsPerRow: parseInt(display_option.columns, 10),
collection: _.isEmpty(this.model.get('items')) ? {} : filteredItems,
cellTemplate: facets_items_collection_view_cell_tpl,
rowTemplate: facets_items_collection_view_row_tpl,
template: facets_items_collection_tpl,
context: {
keywords: this.translator.getOptionValue('keywords')
}
});
}
} else {
var abc = new BackboneCollectionView({
childTemplate: display_option.template,
childView: FacetsItemCellView,
childViewOptions: {
application: this.application
},
viewsPerRow: parseInt(display_option.columns, 10),
collection: _.isEmpty(this.model.get('items')) ? {} : this.model.get('items'),
cellTemplate: facets_items_collection_view_cell_tpl,
rowTemplate: facets_items_collection_view_row_tpl,
template: facets_items_collection_tpl,
context: {
keywords: this.translator.getOptionValue('keywords')
}
});
}
console.log("abc thabcis", abc);
return abc;
},
}),
getContext: _.wrap(FacetsBrowseView.prototype.getContext, function (fn) {
var originalRet = fn.apply(this, _.toArray(arguments).slice(1));
console.log("originalRetoriginalRet", originalRet);
var keyword = this.translator.getOptionValue('keywords');
console.log("keyword", keyword);
if (!!keyword) {
var mycollection = _.isEmpty(this.model.get('items')) ? {} : this.model.get('items');
console.log("mycollection", mycollection);
if (!!mycollection) {
var filteredItems = mycollection.filter(function (models) {
return models.get('domain') === "82";
});
console.log("filteredItems", filteredItems);
var totallength = filteredItems.length
}
} else {
totallength = this.model.get('total');
}
originalRet.total = totallength;
return originalRet;
})
});
