magento2
magento2 copied to clipboard
MAGETWO-99236 Fix for #22063 Category data is changed after saving category linkfor different stores
Description (*)
When there is a loop going through a few products and linking those products to categories. Some categories get data copied from another store.
Load a category from the default store instead of taking the last cached from CategoryRepository.
I think it would also be better to save the category via its repository. Unfortunately the CategoryRepository ignores posted products
$category->setPostedProducts($productPositions);
(probably a case for another bug)
Related Pull Requests
Fixed Issues (if relevant)
- Fixes magento/magento2#22063
- Fixes magento/magento2#32478
Manual testing scenarios (*)
- Create a few stores
- Give different descriptions and short descriptions to a category in each store.
- Loop through different stores e.g. with emulation or just load categories based on product store id
- Link a product to a category.
- Category has correct data (data was not copied from the category instance that loaded in different store)
\Magento\Catalog\Model\CategoryRepository::get
Questions or comments
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)
- [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)