Skip to content

Product Display Page: Error: Call to a member function getId() on bool in vendor/magento/module-catalog/Block/Product/ListProduct.php:464 #34039

@nbennett25

Description

@nbennett25

Preconditions (*)

  1. Magento 2.4.2-p2

Steps to reproduce (*)

  1. Go to Product Display page with product assigned to at least one category

Expected result (*)

  1. Product display page is rendered

Actual result (*)

  1. Error is thrown (developer mode)

Stack trace:
Error: Call to a member function getId() on bool in /var/www/html/vendor/magento/module-catalog/Block/Product/ListProduct.php:464

This appears to be related to the change in the Magento\Catalog\Block\Product\ListProduct class, converting to the use of the current method:

462             if ($categories->count()) {
463                 // show products from this category
464                 $this->setCategoryId(current($categories->getIterator())->getId());
465             }

Converting this to use the built in current() method in the ArrayIterator class works as expected:

462             if ($categories->count()) {
463                 // show products from this category
464                 $this->setCategoryId($categories->getIterator()->current()->getId());
465             }

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ x] 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”.

Metadata

Metadata

Labels

Issue: Cannot ReproduceCannot reproduce the issue on the latest `2.4-develop` branchIssue: needs updateAdditional information is require, waiting for responseReported on 2.4.2Indicates original Magento version for the Issue report.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions