Skip to content

Object of class Magento\Framework\Phrase could not be converted to int on loading catalog product view page #35909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 5 tasks
ivanko-dev opened this issue Aug 10, 2022 · 16 comments
Assignees
Labels
duplicate Reported on 2.4.5 Indicates original Magento version for the Issue report.

Comments

@ivanko-dev
Copy link
Contributor

Preconditions and environment

  • Magento Enterprise 2.4.5

Steps to reproduce

  1. Set catalog/frontend/list_allow_all to 1
  2. 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”.
@m2-assistant
Copy link

m2-assistant bot commented Aug 10, 2022

Hi @ivanko-dev. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@kamzata
Copy link

kamzata commented Aug 11, 2022

+1

@engcom-November engcom-November added the Reported on 2.4.5 Indicates original Magento version for the Issue report. label Aug 11, 2022
@RedBeardedVikingDK
Copy link

+1

1 similar comment
@digitalbricklayer
Copy link

+1

@aohlrogge
Copy link

I'm having this same issue on Magento Community Edition as well

1 similar comment
@qiangvei
Copy link

I'm having this same issue on Magento Community Edition as well

@gwharton
Copy link
Contributor

Duplicate of #35900

@engcom-Echo engcom-Echo self-assigned this Aug 12, 2022
@m2-assistant
Copy link

m2-assistant bot commented Aug 12, 2022

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
      DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
    1. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Echo
Copy link
Contributor

Hello @ivanko-dev,

Thanks for contribution and collaboration.
Please elaborate more where we can set catalog/frontend/list_allow_all to 1 and provide more information with exact steps and screenshot so that we can reproduce this issue.

Thanks

@engcom-Echo engcom-Echo added the Issue: needs update Additional information is require, waiting for response label Aug 12, 2022
@engcom-Echo
Copy link
Contributor

Hello @ivanko-dev,

Thanks for contribution and collaboration.
We have found this issue is duplicate of #35900. Hence we are closing the issue.

Thanks

@engcom-Echo engcom-Echo added duplicate and removed Issue: needs update Additional information is require, waiting for response labels Aug 12, 2022
@isaacdzca
Copy link

+1

@writyou
Copy link

writyou commented Aug 30, 2022

[2022-08-30T05:45:59.812731+00:00] main.CRITICAL: Exception: Warning: Object of class Magento\Framework\Phrase could not be converted to int in /website/tt/var/view_preprocessed/pub/static/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml on line 1 in /website/tt/vendor/magento/framework/App/ErrorHandler.php:62
Stack trace:
#0 /website/enerart/var/view_preprocessed/pub/static/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml(1): Magento\Framework\App\ErrorHandler->handler()
#1 /website/enerart/var/view_preprocessed/pub/static/app/design/frontend/Enerart/tt/Magento_Catalog/templates/product/list/toolbar.phtml(1): include('...')

@elizad
Copy link

elizad commented Sep 4, 2022

1 exception(s):
Exception #0 (Exception): Warning: Object of class Magento\Framework\Phrase could not be converted to int in /var/www/html/m245/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml on line 26

Exception #0 (Exception): Warning: Object of class Magento\Framework\Phrase could not be converted to int in /var/www/html/m245/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml on line 26

#1 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#2 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#3 Magento\Framework\View\Element\Template->fetchView() called at [generated/code/Magento/Catalog/Block/Product/ProductList/Toolbar/Interceptor.php:401]
#4 Magento\Catalog\Block\Product\ProductList\Toolbar\Interceptor->fetchView() called at [vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar.phtml:21]

@klein0r
Copy link
Contributor

klein0r commented Sep 21, 2022

Looks like this has been fixed in bb55549

  • Solution 1: Override the limiter.phtml in your theme with that fix
  • Solution 2: Set catalog/frontend/list_allow_all to 0 (default)

@sippsolutions
Copy link
Member

Patch for 2.4.5-p1:

--- vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml
+++ vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar/limiter.phtml
@@ -23,7 +23,9 @@
                     <?php if ($block->isLimitCurrent($_key)):?>
                         selected="selected"
                     <?php endif ?>>
-                    <?= $block->escapeHtml($localeFormatter->formatNumber((int) $_limit)) ?>
+                    <?= $block->escapeHtml(
+                        is_numeric($_limit) ? $localeFormatter->formatNumber((int) $_limit) : $_limit
+                    ) ?>
                 </option>
             <?php endforeach; ?>
         </select>

@jmilanovy
Copy link

Having set this:
Set catalog/frontend/list_allow_all to 1
Products were not showing in categories. Set it back to 0 and everything was fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Reported on 2.4.5 Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests