Sync combination updates made via legacy Product::updateAttribute() (StoreCommander & bulk tools) - #7
Open
Pichinov-Jose wants to merge 1 commit into
Conversation
…te() StoreCommander and other bulk catalog tools update product combinations through the legacy Product::updateAttribute() API, which fires actionProductAttributeUpdate and NOT actionObjectCombinationUpdateAfter. The module was neither registered on that hook nor had a handler for it, so those combination changes were never committed to Splash. Stock still synced (via actionUpdateQuantity), but attribute / price impact / reference changes on combinations were silently lost. Register actionProductAttributeUpdate and add a handler that rebuilds the Combination from id_product_attribute and forwards it to the existing hookActionCombination commit logic (which already checks the onCombinationLock guard, so no sync loop when Splash itself writes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When product combinations are updated through PrestaShop's legacy
Product::updateAttribute()API — the path used by StoreCommander and other bulk catalog managers — SplashSync does not sync the change. Stock is synced (viaactionUpdateQuantity), but combination attribute changes (price impact, reference, EAN13…) are silently lost.Root cause
Combination changes are captured only through the ObjectModel hooks in
src/Objects/Product/HooksTrait.php:hookActionObjectCombinationAddAfterhookActionObjectCombinationUpdateAfterhookActionObjectCombinationDeleteAfterThese
actionObjectCombination*Afterhooks fire only when aCombinationis saved through the ObjectModel ($combination->update()).The legacy
Product::updateAttribute()(inclasses/Product.php) does not save aCombinationObjectModel — it fires:The module is neither registered on
actionProductAttributeUpdatenor has a handler for it (verified up tomaster/ 2.9.3), so those combination updates never reach Splash.Note the pre-existing asymmetry: the module registers
actionProductAttributeDeletebut notactionProductAttributeUpdate.Fix
actionProductAttributeUpdateininstall().hookActionProductAttributeUpdate()inHooksTrait, which rebuilds theCombinationfromid_product_attributeand forwards it to the existinghookActionCombination()commit logic.The handler reuses the existing engine, so the
onCombinationLockguard already prevents a sync loop when Splash itself writes the combination. It is a no-op when the id is missing or the combination can't be loaded.How to reproduce
Product::updateAttribute()), not the native BO combination form.Tested
Deployed in production (PrestaShop 1.7 / PHP 8.1) alongside StoreCommander: combination edits from SC now commit correctly (
Product Variant Updated on Prestashop) and reach the connected node, with no sync loop and no regression on native BO edits.