سؤال

I want to override magento default search result, what I want to do is if products are not assign to any category then those products are not display on frontend in search result, by default magento include those products also which are not assign to any category.

I know magento prepare search result collection here prepareProductCollection($collection) in layer.php file but how we can exclude product without category?

هل كانت مفيدة؟

المحلول

I think the best solution here is to change the visibility of the products you don't want to show on search to 'Catalog' instead of 'Catalog,Search' (or 'Not visible individually'), instead of changing the way that the search results are fetched.
You can run a script to check the products that are not assigned to any category (attribute category_ids is null) and change the value of 'visibility'.

نصائح أخرى

If you change top level category option Is Anchor to No, magento will return products only assigned to subcategories.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top