0

I want to change the default functionality of search in visibility. When product Visibility is set to Search or Not Visible Individually it should not appear in the search dropdown, search results, or category pages.

Does anyone know the path to change it?

2
  • Before asking a new question, you should accept the answer to your previous questions.
    – Keyur Shah
    May 10, 2019 at 13:24
  • @KeyurShah I already have May 13, 2019 at 11:35

3 Answers 3

1

For Product Listing Page Copy This File in Your Theme

/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

For Search Result Copy This File in Your Theme

 /var/www/html/vendor/magento/module-catalog-search/view/frontend/templates/advanced/result.phtml

In This File You Can Apply Filter On Collection.

$collection->addAttributeToFilter('visibility', \Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG); 
0

You can change this in backend:

  1. click edit product and change Visibility attribute.

    or

  2. select few products and select change attributes => change visibility.

enter image description here

4
  • I want search functionality to behave like not visible individually May 10, 2019 at 9:39
  • You have option Not Visible Individually
    – BartZalas
    May 10, 2019 at 9:44
  • yes, but the client wants the search to work like not visible individually May 10, 2019 at 9:45
  • Do you want to hide search bar or products? If You check in product "Not visible Individually" this will hide this product.
    – BartZalas
    May 10, 2019 at 10:02
0

You need to Extension setVisibility method of below class:

vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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