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

Fixed indexed product positions for anchor categories. #9393

Merged

Conversation

obuchowski
Copy link
Member

@obuchowski obuchowski commented Apr 25, 2017

Description

Indexed product positions saved in catalog_category_product_index table are incorrect for those products which could be found in child categories.

Manual testing scenarios

Initial data:
Category 2 (category with id == 2) is anchor.
Category 37 (category with id == 37) is category's 2 child

1.1. Append product to a category 2. Set its position to 2.
1.2. Run php bin/magento indexer:reindex catalog_product_category
1.3. The result is CORRECT (both catalog_category_product and catalog_category_product_index tables shows a product position == 2)
anchor_only
1.4. Remove a product from a category 2

2.1. Append a product to a category 37. Set its position to 3.
2.2. Run php bin/magento indexer:reindex catalog_product_category
2.3. The result is CORRECT (position == 3 for a category 37 and 10000 + 3 for an anchor category 2)
child_only

3.1. Repeat a step#1.1 ( Append product to a category 2. Set its position to 2.)
3.2. Run php bin/magento indexer:reindex catalog_product_category
3.3. The result is INCORRECT (position for a product in a category 2 in the table catalog_category_product_index should be 2. But it is 10000 + 3 like in the second scenario)
anchor_and_child

Fixed Issues

Position for a product assigned to anchor categories is indexed currectly whether or not it has entries in child categories.
anchor_and_child_fixed

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 25, 2017

CLA assistant check
All committers have signed the CLA.

@akaplya
Copy link
Contributor

akaplya commented May 17, 2017

Hi @EObukhovsky Thank you for your contribution!
Can you provide more input about the issue. The way how product was assigned (UI/API)? Selected indexer mode?

@obuchowski
Copy link
Member Author

obuchowski commented May 22, 2017

Hi @akaplya ,
I personally tested it on products from a sample data.
Indexer mode was "update on save".
But I believe it doesn't matter since this part of indexer doesn't depend on such things, it just operates with database entities.
If a product is assigned to an anchor category and this product is also assigned to this anchor category's child then position from the anchor is ignored.
For example magento1 processes this situation correctly.
https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php#L537

@okorshenko
Copy link
Contributor

@akaplya any progress on this?

@Ctucker9233
Copy link

@magento-team can this be backported to 2.2?

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