InsideDarkWeb.com

Message on category page

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

Magento Asked on October 2, 2021

1 Answers

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!

Related Questions

is creating block within template in magento 2 good practice

0  Asked on July 24, 2020 by herve-tribouilloy

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.