[14.0][FIX] connector_woocommerce: relink already existing products on export - #941
Open
deeniiz wants to merge 3 commits into
Open
[14.0][FIX] connector_woocommerce: relink already existing products on export#941deeniiz wants to merge 3 commits into
deeniiz wants to merge 3 commits into
Conversation
…alt key When the external alternate key computed from the export mapper has null fields, to_binding_from_internal_key gave up without any chance to find the existing external record, so the exporter always created a new one. Extract the post-search binding logic into _to_binding_from_external_record and call a new overridable hook _get_external_record_alt_fallback when the key is incomplete. The default implementation returns no record, keeping the previous behaviour for all connectors.
A variable product template exports sku=None on purpose (the SKUs belong to its variations), so the alternate-key re-match could never find it: exporting a variable product whose parent already existed on WooCommerce but had no binding always created a duplicate parent product. Implement the incomplete-alt-key fallback for the template binder: derive the external parent through one of the template variations, either from an already bound variation (woocommerce_idparent) or searching a variation by SKU and reading its parent_id.
Non-master languages never export the SKU, so their alternate key is always incomplete and the re-match gave up before reaching the existing translations-based redirect: exporting a product whose translations already existed on WooCommerce but had no bindings always created duplicated translations (and re-pointed the WPML translation slots to them, orphaning the originals). Implement the incomplete-alt-key fallback on the WPML binder mixin: reach the external record through the master language binding and follow its translations to the requested language. Extract the duplicated language-redirect logic from the template and variation binders into the mixin, and fix the variation translation read, which needs the parent product of the requested language (resolved through the template binding).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 14.0 #941 +/- ##
==========================================
- Coverage 51.49% 51.43% -0.06%
==========================================
Files 1182 1182
Lines 20438 20484 +46
Branches 4299 4308 +9
==========================================
+ Hits 10524 10536 +12
- Misses 9658 9693 +35
+ Partials 256 255 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
No description provided.