Skip to content

Sync combination updates made via legacy Product::updateAttribute() (StoreCommander & bulk tools) - #7

Open
Pichinov-Jose wants to merge 1 commit into
SplashSync:masterfrom
Pichinov-Jose:feat/product-attribute-update-hook
Open

Sync combination updates made via legacy Product::updateAttribute() (StoreCommander & bulk tools)#7
Pichinov-Jose wants to merge 1 commit into
SplashSync:masterfrom
Pichinov-Jose:feat/product-attribute-update-hook

Conversation

@Pichinov-Jose

Copy link
Copy Markdown

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 (via actionUpdateQuantity), 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:

  • hookActionObjectCombinationAddAfter
  • hookActionObjectCombinationUpdateAfter
  • hookActionObjectCombinationDeleteAfter

These actionObjectCombination*After hooks fire only when a Combination is saved through the ObjectModel ($combination->update()).

The legacy Product::updateAttribute() (in classes/Product.php) does not save a Combination ObjectModel — it fires:

Hook::exec('actionProductAttributeUpdate', ['id_product_attribute' => (int) $id_product_attribute]);

The module is neither registered on actionProductAttributeUpdate nor has a handler for it (verified up to master / 2.9.3), so those combination updates never reach Splash.

Note the pre-existing asymmetry: the module registers actionProductAttributeDelete but not actionProductAttributeUpdate.

Fix

  • Register actionProductAttributeUpdate in install().
  • Add hookActionProductAttributeUpdate() in HooksTrait, which rebuilds the Combination from id_product_attribute and forwards it to the existing hookActionCombination() commit logic.

The handler reuses the existing engine, so the onCombinationLock guard 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

  1. Connect a node (e.g. Dolibarr).
  2. Update a combination's reference / EAN13 / price impact via StoreCommander (which calls Product::updateAttribute()), not the native BO combination form.
  3. Before this fix: no commit is emitted. After: the combination is committed like a native ObjectModel update.

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.

…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>
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.

1 participant