5

I'm not sure, how this state was reached. I also tried one new category and added one new product. The product is definitely set to be visible in Catalogue and Search, but the category still doesn't listen to it.

I don't see any code overriding catalog_category_view.xml content.
By adding HTML before $this->getChildHtml('product_list') in getProductListHtml method in vendor/magento/module-catalog/Block/Category/View.php I see, that it's definitely called.
I can also see inside vendor/magento/module-catalog/Block/Product/ListProduct.php, that the product collection is not empty.
I can see that neither vendor/magento/module-catalog/view/frontend/templates/product/list.phtml nor vendor/magento/module-catalog/view/frontend/templates/product/listing.phtml is being called, as no static HTML lands in the output.

Where could I look at what prevents the products from being listed?

1 Answer 1

2

That is a Magento core issue, it is fixed and will update in the next release: https://github.com/magento/magento2/issues/35900

Related commit: https://github.com/magento/magento2/commit/bb55549cd3016987663272e7ffe3f452c8d6e40d

There are 2 ways you can applying the fix:

  1. You can apply this patch to resolve that issue: https://github.com/magento/magento2/commit/bb55549cd3016987663272e7ffe3f452c8d6e40d.diff

  2. You can override vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml in your theme. Create app/design/frontend/VendorName/ThemeName/Magento_Catalog/templates/product/list/toolbar/limiter.phtml file with the following content.

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/**
 * Product list toolbar
 *
 * @var \Magento\Catalog\Block\Product\ProductList\Toolbar $block
 * @var \Magento\Framework\Locale\LocaleFormatter $localeFormatter
 */
?>
<div class="field limiter">
    <label class="label" for="limiter">
        <span><?= $block->escapeHtml(__('Show')) ?></span>
    </label>
    <div class="control">
        <select id="limiter" data-role="limiter" class="limiter-options">
            <?php foreach ($block->getAvailableLimit() as $_key => $_limit):?>
                <option value="<?= $block->escapeHtmlAttr($_key) ?>"
                    <?php if ($block->isLimitCurrent($_key)):?>
                        selected="selected"
                    <?php endif ?>>
                    <?= $block->escapeHtml(
                        is_numeric($_limit) ? $localeFormatter->formatNumber((int) $_limit) : $_limit
                    ) ?>
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <span class="limiter-text"><?= $block->escapeHtml(__('per page')) ?></span>
</div>

If you feel it too hard to apply the fix, you can temporary disable the feature "Allow All Products per Page" from admin: Admin menu > Stores > Configuration > Catalog > Catalog > Storefront > Set Allow All Products per Page to No.

6
  • vendor/magento/module-catalog/view/frontend/templates/category/products.phtml is definitely executed with the <?= $block->getProductListHtml() ?>. I checked the folder /app/design/frontend/ and there is definitely no theme overwriting and I'm using the original Magento/luma theme from the vendor folder. I also checked the category tree and don't have any design or layout update set.
    – rarog4k
    Oct 23, 2022 at 8:06
  • I have a general suspicion now: There is an exception thrown before the product list is drawn. Both in system.log and debug log I can find a stack trace starting with this: [2022-10-23T08:18:47.295760+00:00] main.CRITICAL: Exception: Warning: Object of class Magento\Framework\Phrase could not be converted to int in /.../vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml on line 26 in /.../vendor/magento/framework/App/ErrorHandler.php:62
    – rarog4k
    Oct 23, 2022 at 8:22
  • Cool, that is Magento core issue. I've added the solution to my answer, please check and don't forget to mark the answer as accepted as it will help others who have the same issue easier to find the answer.
    – Tu Van
    Oct 23, 2022 at 9:05
  • Okay, looks like I was hit by the bug github.com/magento/magento2/issues/35900 and the solution won't be published until 2.4.6 in March 2023. Obviously this wasn't important enough to be incorporated into 2.4.5-p1. I'll override the faulty phtml in my theme that I'll create for such kind of bug.
    – rarog4k
    Oct 23, 2022 at 9:14
  • Yes, thx, I've seen, that you just posted the solution I found simultanously, I just was researching hot to override the phtml in own theme, thx for the help!
    – rarog4k
    Oct 23, 2022 at 9:16

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.