magento2: Object of class Magento\Framework\Phrase could not be converted to int on loading catalog product view page
Preconditions and environment
- Magento Enterprise 2.4.5
Steps to reproduce
- Set catalog/frontend/list_allow_all to 1
- Open catalog product view page
Expected result
Page loaded with no errors
Actual result
Error on loading appears: Exception #0 (Exception): Warning: Object of class Magento\Framework\Phrase could not be converted to int in /path_to_project/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml on line 26
Additional information
Magento 2.4.5 content of vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml Lines 21-28:
<?php foreach ($block->getAvailableLimit() as $_key => $_limit):?>
<option value="<?= $block->escapeHtmlAttr($_key) ?>"
<?php if ($block->isLimitCurrent($_key)):?>
selected="selected"
<?php endif ?>>
<?= $block->escapeHtml($localeFormatter->formatNumber((int) $_limit)) ?>
</option>
<?php endforeach; ?>
Previous verisons:
<?php foreach ($block->getAvailableLimit() as $_key => $_limit) :?>
<option value="<?= $block->escapeHtmlAttr($_key) ?>"
<?php if ($block->isLimitCurrent($_key)) :?>
selected="selected"
<?php endif ?>>
<?= $block->escapeHtml($_limit) ?>
</option>
<?php endforeach; ?>
Same time in vendor/magento/module-catalog/Helper/Product/ProductList.php Lines 134-138:
if ($this->scopeConfig->isSetFlag('catalog/frontend/list_allow_all', ScopeInterface::SCOPE_STORE)) {
return ($perPageValues + ['all' => __('All')]);
} else {
return $perPageValues;
}
As result code in template https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar/limiter.phtml#L26 not designed to accept value, which assigned in https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Helper/Product/ProductList.php#L135 if catalog/frontend/list_allow_all enabled
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 16 (5 by maintainers)
Looks like this has been fixed in bb55549cd3016987663272e7ffe3f452c8d6e40d
catalog/frontend/list_allow_all
to0
(default)Patch for 2.4.5-p1: