문제

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