Skip to content

Conversation

@berliozd
Copy link

A category instance is passed when a category id is supposed to be received.

Description

In magento2/app/code/Magento/Catalog/Block/Product/ListProduct.php, in _getProductCollection function, the following code set categoryId with a category instance.

// if the product is associated with any category
                if ($categories->count()) {
                    // show products from this category
                    $this->setCategoryId(current($categories->getIterator()));
                }

That causes the following code to fail later :
$category = $this->categoryRepository->get($this->getCategoryId());

Manual testing scenarios

  1. In the backoffice, add a product to the upsell product list
  2. Go to the frontend product page to verify the bug is occuring
    You should have the following error :

Exception #0 (Exception): Warning: Illegal offset type in /var/www/html/_0521-barbarabui/vendor/magento/module-catalog/Model/CategoryRepository.php on line 133

  1. After the fix the bug doesn't occur anymore.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Oct 18, 2017

CLA assistant check
All committers have signed the CLA.

@orlangur orlangur self-assigned this Oct 18, 2017
@orlangur
Copy link
Contributor

@berliozd thanks for your contribution!

Seems to be a backport of #7598 (fix present in 2.2), if this test will fail it can be added from that PR.

@orlangur orlangur added this to the October 2017 milestone Oct 19, 2017
@vrann
Copy link
Contributor

vrann commented Oct 24, 2017

@berliozd can you please help with the testing of this PR? Here is a video on how it been tested, but issue can't be reproduced.
upsell.zip

@okorshenko okorshenko modified the milestones: October 2017, November 2017 Nov 1, 2017
@ishakhsuvarov
Copy link
Contributor

Hi @berliozd
Would you still like to proceed with this PR? Please check the comment above if so.
Thanks!

@orlangur
Copy link
Contributor

Although this PR is a carbon copy of https://github.com/magento/magento2/pull/7598/files I don't think merging it without testing is a good idea.

@berliozd, I'm closing this PR for now due to inactivity. Feel free to reach me out anytime later if you manage to find steps to reproduce issue and this PR will be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants