Basically I want to show static content using a block on my category menu in Magento 2.3.5. I have created a category and set Display Mode as Static Block only, Anchor set to No and Added a block from Add CMS Block dropdown, but the issue is when I try to browse this category it shows
We can't find products matching the selection.
How to hide this message.
Add a comment
|
1 Answer
The message We can't find products matching the selection. comes from the file /magento/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
.
You need to override the list.phtml
file in your custom module or theme to hide the message.
Example:
<?php
/**
* Product list template
*
* @see \Magento\Catalog\Block\Product\ListProduct
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper(Magento\Catalog\Helper\Output::class);
?>
<?php if (!$_productCollection->count()) :?>
// ---------------------- comment or remove the below code ------------------------------
<div class="message info empty"><div><?= $block->escapeHtml(__('We can\'t find products matching the selection.')) ?></div></div>
<?php else :?>
<?= $block->getToolbarHtml() ?>
<?= $block->getAdditionalHtml() ?>
....
....
I hope this helps!
-
-
@ishaq You need to copy the original file in your child theme and apply the changes. Copy file to the child theme
app\design\frontend\<VENDOR_NAME>\<THEME_NAME>\Magento_Catalog\templates\product\listing.phtml
and make the code changes. Commented Jul 19, 2020 at 12:22 -
still, no way put this file in my custom theme but the message is still there deployed static content and cleaned and flushed cache also. put file in this location and commented the code
/var/www/html/app/design/frontend/Airosoconnect/base/Magento_Catalog/templates/product
– ishaqCommented Jul 19, 2020 at 12:49 -
<!-- <p class="message note"><?= $block->escapeHtml(__('We can\'t find products matching the selection.')) ?></p> -->
updated this line in listing.phtml file– ishaqCommented Jul 19, 2020 at 12:50 -
Try removing the
<?= $block->escapeHtml(__('We can\'t find products matching the selection.')) ?>
and removerm -rf var/* generated/* pub/static/*
, re-run static content deploy, clear the cache and check again. Commented Jul 19, 2020 at 13:07