EmicoEcommerce / Magento2AttributeLandingTweakwise

Use Magento 2 landing pages with Tweakwise navigator
Other
0 stars 2 forks source link

Filters linking to attribute landing pages don't care about store id #5

Closed teun-sinkeldam-iodigital closed 1 year ago

teun-sinkeldam-iodigital commented 1 year ago

This is an issue that also needs to be solved in https://github.com/EmicoEcommerce/Magento2AttributeLanding

Steps to reproduce:

  1. Have a Magento 2 installation with multiple stores
  2. Make an attribute landing page based on a category and tweakwise filter
  3. Set the store id of the landing page to one of the stores
  4. Go to the store that is NOT set on the landing page
  5. On the category page click on the filter that you set up in the landing page

Result: The FilterManager finds the landing page, changes the filter url to the landing page url and when you click it, you see the 404 page

Expected result: For the current store there is no attribute landing page set up, so just add the filter to the url as a regular filter.

Probable cause: The urls of the filters are fetched with this code:

if ($url = $this->urlFinder->findUrlByFilters($filters, $layer->getCurrentCategory()->getEntityId())) {
    return $url;
}

What is missing here is that the store id also matters when finding urls. The UrlFinder mentioned in the code is from https://github.com/EmicoEcommerce/Magento2AttributeLanding. The UrlFinder currently also does not accept a parameter for the store id, but I think that it should, for this case specifically.