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

Fix wrong store id filter #9430

Merged
merged 2 commits into from
Jun 7, 2017
Merged

Conversation

mimarcel
Copy link
Contributor

@mimarcel mimarcel commented Apr 27, 2017

Description

Website id is incorrectly used for store filter when retrieving products on category page. Store id should be used instead.

Manual testing scenarios

  1. Having the following store structure:
    store_website
    store

  2. When i access a category page on store Store View 2, no products are displayed because of wrong filter.
    Example: Go to http://local-magento2/storeview2/test-some-category-path.html

  3. When debugging the category page, at \Magento\Framework\Search\Adapter\Mysql\TemporaryStorage::storeDocumentsFromSelect, the expression $select . '' is evaluated to:

SELECT `main_select`.`entity_id`, MAX(score) AS `relevance` FROM (SELECT `search_index`.`entity_id`, (((0) + (0)) * 1) AS `score` FROM `catalogsearch_fulltext_scope5` AS `search_index`
 INNER JOIN `catalog_category_product_index` AS `category_ids_index` ON search_index.entity_id = category_ids_index.product_id
 LEFT JOIN `catalog_product_index_eav` AS `visibility_filter` ON search_index.entity_id = visibility_filter.entity_id AND visibility_filter.attribute_id = 99 AND visibility_filter.store_id = 4
 LEFT JOIN `cataloginventory_stock_status` AS `visibility_filter_stock` ON visibility_filter_stock.product_id = visibility_filter.source_id
 INNER JOIN `cataloginventory_stock_status` AS `stock_index` ON search_index.entity_id = stock_index.product_id AND stock_index.website_id = 0 WHERE (stock_index.stock_status = 1) AND (category_ids_index.category_id = 3) AND (visibility_filter.value  IN ('2','4') AND visibility_filter_stock.stock_status = 1)) AS `main_select` GROUP BY `entity_id` ORDER BY `relevance` DESC
 LIMIT 10000

This query returns empty result. Changing visibility_filter.store_id = 4 to visibility_filter.store_id = 5, the query returns the expected products from category.
Note that the Website 2 has id 4 and Store View 2 has id 5.

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 Apr 27, 2017

CLA assistant check
All committers have signed the CLA.

@avoelkl avoelkl self-assigned this May 26, 2017
@avoelkl avoelkl added this to the May 2017 milestone May 26, 2017
@okorshenko okorshenko modified the milestones: May 2017, June 2017 Jun 1, 2017
@okorshenko okorshenko self-assigned this Jun 6, 2017
@magento-team magento-team merged commit e29415e into magento:develop Jun 7, 2017
magento-team pushed a commit that referenced this pull request Jun 7, 2017
@magento-team
Copy link
Contributor

@mimarcel thank you for your contribution

@mimarcel mimarcel deleted the fix/wrong_store_id branch June 27, 2017 07:47
@gjportegies
Copy link

Will this fix be ported to 2.1?

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

Successfully merging this pull request may close these issues.

None yet