Commit d507eb50cd3 for woocommerce
commit d507eb50cd30677e2df881f7c3850ef86ef44ca6
Author: Chris Lilitsas <1105590+xristos3490@users.noreply.github.com>
Date: Mon Jul 6 15:56:15 2026 +0300
Fix: Prevent Webflow migrator from clearing weight on field-filtered re-runs (#66316)
* fix: prevent Webflow migrator from clearing weight on field-filtered re-runs
* test: cover Webflow mapper omitting weight key on field-filtered runs
* chore: remove changelog entry
diff --git a/plugins/woocommerce/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapper.php b/plugins/woocommerce/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapper.php
index 11bb190bc89..ddac638528d 100644
--- a/plugins/woocommerce/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapper.php
+++ b/plugins/woocommerce/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapper.php
@@ -375,7 +375,6 @@ class WebflowMapper implements PlatformMapperInterface {
'manage_stock' => false,
'stock_quantity' => null,
'stock_status' => 'instock',
- 'weight' => null,
'tax_status' => 'taxable',
);
@@ -488,7 +487,6 @@ class WebflowMapper implements PlatformMapperInterface {
'manage_stock' => false,
'stock_quantity' => null,
'stock_status' => 'instock',
- 'weight' => null,
'tax_status' => 'taxable',
'attributes' => array(),
'image_original_id' => null,
diff --git a/plugins/woocommerce/tests/php/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapperTest.php b/plugins/woocommerce/tests/php/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapperTest.php
index d219690baed..121efef641d 100644
--- a/plugins/woocommerce/tests/php/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapperTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/CLI/Migrator/Platforms/Webflow/WebflowMapperTest.php
@@ -211,6 +211,43 @@ class WebflowMapperTest extends \WC_Unit_Test_Case {
$this->assertNull( $by_sku['HOOD-BLUE-M']['height'] );
}
+ /**
+ * @testdox Simple product omits the weight key entirely when weight is excluded from the fields to process.
+ */
+ public function test_simple_product_omits_weight_key_when_field_excluded(): void {
+ $mapper = new WebflowMapper( array( 'fields' => array( 'price', 'sku' ) ) );
+
+ $result = $mapper->map_product_data( MockWebflowData::simple_product_item() );
+
+ // The importer only touches weight when the key is present (array_key_exists), so an
+ // excluded field must leave the key absent rather than null — a null would clear the
+ // existing product's weight on a field-filtered re-run.
+ $this->assertArrayNotHasKey( 'weight', $result, 'Excluded weight field must not leave a null weight key.' );
+ }
+
+ /**
+ * @testdox Simple product includes the weight key when weight is among the fields to process.
+ */
+ public function test_simple_product_includes_weight_key_by_default(): void {
+ $result = $this->mapper->map_product_data( MockWebflowData::simple_product_item() );
+
+ $this->assertArrayHasKey( 'weight', $result, 'Weight key must be present when the field is processed.' );
+ }
+
+ /**
+ * @testdox Variations omit the weight key entirely when weight is excluded from the fields to process.
+ */
+ public function test_variation_omits_weight_key_when_field_excluded(): void {
+ $mapper = new WebflowMapper( array( 'fields' => array( 'price', 'sku' ) ) );
+
+ $result = $mapper->map_product_data( MockWebflowData::variable_product_item() );
+
+ $this->assertNotEmpty( $result['variations'], 'Fixture should produce variations.' );
+ foreach ( $result['variations'] as $variation ) {
+ $this->assertArrayNotHasKey( 'weight', $variation, 'Excluded weight field must not leave a null weight key on variations.' );
+ }
+ }
+
/**
* Test SEO fields land in metafields.
*/