Skip to content

[14.0][FIX] connector_woocommerce: relink already existing products on export - #941

Open
deeniiz wants to merge 3 commits into
14.0from
14.0-fix-connector_woocommerce-export_relink_existing
Open

[14.0][FIX] connector_woocommerce: relink already existing products on export#941
deeniiz wants to merge 3 commits into
14.0from
14.0-fix-connector_woocommerce-export_relink_existing

Conversation

@deeniiz

@deeniiz deeniiz commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

deeniiz added 3 commits July 3, 2026 13:27
…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

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.94915% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.43%. Comparing base (89b9375) to head (46a6bf3).
⚠️ Report is 1 commits behind head on 14.0.

Files with missing lines Patch % Lines
...ocommerce_wpml/models/product_wpml_mixin/binder.py 20.00% 16 Missing ⚠️
...ctor_woocommerce/models/product_template/binder.py 7.14% 13 Missing ⚠️
..._woocommerce_wpml/models/product_product/binder.py 15.38% 11 Missing ⚠️
...woocommerce_wpml/models/product_template/binder.py 16.66% 5 Missing ⚠️
connector_extension/components/binder.py 33.33% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants