Restrict the items based on subsidiary for all the global searches including plp page without getting issue in pagination and total items.

using this Methode we can restrict the items for the Seach using Api based on subsider in the profile model we can get the API using that Api we can restrict the items on the search and PLP if we are using the Custome field then we also we need to add that fields in the facets we cannot use the Custome fields directly in the Api.

_.extend(ProfileModel.prototype, {
				//This function is used to update the searchAPI based on the subsidery.
				getSearchApiUrl: function () {
				  if (
					Configuration.getRegistrationType() !== "disabled" &&
					(Configuration.get("siteSettings.requireloginforpricing", "F") ===
					  "T" ||
					  Configuration.get("siteSettings.siteloginrequired", "F") ===
					  "T") &&
					this.get("isLoggedIn") === "T"
				  ) {
					let url = Utils.getAbsoluteUrl("searchApi.ssp") + '?' + allowedSubsidiaries[subsidiary] + '=true';
					return url;
				  }
				  return "/api/items";
				},
			  });

Leave a comment

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