OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
863 stars 438 forks source link

Saving product from backend causes destroying category product positions in anchor categories. #4054

Open alexherbs opened 5 days ago

alexherbs commented 5 days ago

I have found an issue in the openmage core which destroys category product positions in anchor categories.

When I save the product from the magento backend we get positions in anchor categories like: 80003 When the "catalog category product" index is processing all products we get positions in anchor categories like: 20003 This different positions calculations generate wrong orders in our catalog. I expect that the positions should be the same, either I save the product in backend or I run the index, but they are not.

I have checked the code and found differences between the catalogProductSave function and the indexer reindexAll function. Both functions have different calculations which should be changed to one way.

catalogProductSave function app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php Line: 559 Code-Line: (cc.position + 1) + (cc.level +1) * 10000 + cp.position

reindexAll function app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php Line: 896 Code-Line: (cc.position + 1) (cc.level + 110000) + cp.position

The way the positions are calculations should be the same and we should decide us for one way. Either from the catalogProductSave of from the reindexAll function.

For me this change fixed my problem, but it also could be that the position calculating in reindexAll is wrong. grafik

Regards, Alexander Herbel