TransWikia.com

Message on category page

Magento Asked on October 2, 2021

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.
enter image description here

One 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 MagentoCatalogBlockProductListProduct
 */
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper(MagentoCatalogHelperOutput::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!

Correct answer by Bhaumik Upadhyay on October 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP