Skip to content
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

Wrong breadcrumbs due to last visited category being virtual category #3082

Open
setura opened this issue Oct 10, 2023 · 3 comments
Open

Wrong breadcrumbs due to last visited category being virtual category #3082

setura opened this issue Oct 10, 2023 · 3 comments

Comments

@setura
Copy link

setura commented Oct 10, 2023

When we visit a virtual category page and then visit a product page of a product that doesn't belong to the last visited virtual category, we will see the virtual category page of the last category visited in the breadcrumbs instead of "home" -> "product name". When searching products we should not see categories on breadcrumbs.

Preconditions

Replicable in every env. Using M1 chip with valet for PHP and Nginx and docker for redis, Open search, and database

Magento Version : 2.4.5-p3

ElasticSuite Version: smile/elasticsuite 2.10.13.3

But this issue also happens on smile/elasticsuite 2.10.18.1

Environment : Reproducible in both modes

Third party modules : None seem to impact this feature directly.

Steps to reproduce

  1. Create a virtual category with some products and visit it
  2. Go to another product that doesn't belong to this virtual category
  3. Check the category of the breadcrumbs, it will show the virtual category as it was the last category visited.

Expected result

  1. When searching for products we should not see categories on breadcrumbs.

Actual result

  1. We see the Virtual category of this product

The is where the issue happens. Basically, since the last visited category is a virtual, this plugin will return true.
\Smile\ElasticsuiteVirtualCategory\Plugin\Catalog\ProductPlugin::aroundCanBeShowInCategory

Screenshot 2023-10-10 at 12 36 53

Then this line is evaluated to true vendor/magento/module-catalog/Helper/Product.php:446 which will set the categoryID to the virtual category.

Ultimately the this line sets the wrong product category to the product

vendor/magento/module-catalog/Helper/Product.php:461

@setura
Copy link
Author

setura commented Oct 10, 2023

My solution for this was an after plugin to Magento\Search\Controller\Ajax\Suggest:afterExecute setting
$this->catalogSession->setLastVisitedCategoryId(null);

\Magento\Catalog\Model\Session $catalogSession

@vahonc
Copy link
Collaborator

vahonc commented Oct 16, 2023

Hello @setura, thanks for your feedback.

Yes, it looks like the logic of aroundCanBeShowInCategory plugin is not up to date, so from out-of-the-box we don't have a fix for this issue now.

Your fix is a little bit dirty, but in your case, it can fix your issue.

We will try to come back to this and fix it in the proper way in our feature releases.

BR,
Vadym

@setura
Copy link
Author

setura commented Oct 16, 2023

Agreed @vahonc, it is a temporary solution for sure.

Best regards,
Pedro Amaro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants