how i can hide products from catalog listing only but keep showing them in search result page using css like display: none;, is there a way to create a customer ID for the specific products that i want to hide and control the visibility via css?


There is a default setting in Magento where you can define visibility of your products.

If you set this option for "Search" - Products will be visible on Search Result Page

If you set this option for "Catalog" - Products will be visible on Catalog Listing Page

If you set this option for "Catalog, Search" - Products will be visible on both Catalog Listing Page and Search Result Page

enter image description here

Solution 2: I will not recommend (the way you want)

  • Create Boolean Attribute at product level (Yes/No)
  • call that attribute in your tag <li> tag

<li class="item product product-item <?php if($_product->getAttributeText('attribute_code')){ echo 'hide'; } ?>">

In CSS hide { display: none; }

By this way you can hide any product you want. Again I will NOT RECOMMEND this way.

| improve this answer | |
  • thank you for the fast reply, but i want to have some specific product to hide in catalog and show in search – user3005390 Dec 14 '17 at 20:09
  • So you can change this setting for specific products only. Then Re-index and are good to go :) – Abhishek Panchal Dec 14 '17 at 20:10
  • Use default Magento rather then using CSS or some customization – Abhishek Panchal Dec 14 '17 at 20:11

Abhishek it didn't work, my best chance is to use a css class

 `<li class="item product product-item hide">      `

and i will use hide { display: none; }

how i can add css class to a specific product?

| improve this answer | |
  • What do you mean by it didnt work? – Abhishek Panchal Dec 14 '17 at 21:31
  • I updated my answer – Abhishek Panchal Dec 14 '17 at 21:50
  • thank you again :) one last question what file i need to edit to add <?php if($_product->getAttributeText('attribute_code')){ echo 'hide'; } ?> to <li class="item product product-item"> – user3005390 Dec 14 '17 at 21:55
  • I got this error: Parse error: syntax error, unexpected 'attribute_code' (T_STRING) – user3005390 Dec 15 '17 at 14:17
  • Can you please tell me your attribute_code which you created in Admin? – Abhishek Panchal Dec 15 '17 at 14:27

how i can add this line

    `<?php if($_product->getData('hide') == 1) { echo 'hide'; } ?>`


<?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item ***HERE***">' : '</li><li class="item product product-item">' ?>
| improve this answer | |

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.