0

We have created a custom attribute for the product. While searching for product we only want to show the products where this attribute is 'True'.

For example assume that the custom attribute is 'master_record', when searching, show only those product for which 'master_record' is true. Which model class do we need to edit/Override to accomplish this.

1

There is already an attribute for that, "Visibility". You can set it to "Catalog", instead of the default "Catalog/Search" and then the product is still visible, but not searchable anymore.

If for some reason you need to use this other attribute, I'd recommend to write an observer for catalog_product_save_before and set the visibility attribute dependent on the master_record attribute there. This way you don't need to manipulate the collection loading. This would be relatively easy too, with another observer, but you'd need to add your attribute to the flat index and have an additional condition in every search query. I would not recommend to add this needless complexity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.