woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
47 stars 21 forks source link

Prioritise core WooCommerce GTIN field in product adapter #2621

Closed martynmjones closed 2 months ago

martynmjones commented 2 months ago

Changes proposed in this Pull Request:

Closes #2614

Adjusts WCProductAdapter.php to map the GTIN field from WooCommerce core if it's available. This is checked after the attribute mapping rules and Google for WooCommerce attributes as we want to prioritise the core field.

We return early if the product does not have a get_global_unique_id method to maintain backwards compatibility.

Screenshots:

Screenshot 2024-09-20 at 12 20 42

Detailed test instructions:

  1. Checkout update/2614-prioritise-core-gtin-field-in-product-adapter
  2. Set up an attribute mapping rule for GTIN to some field
  3. Create a product and enter different valid GTIN values (for example 00000001, 00000002, 00000003) in
    • The core GTIN field on the Inventory tab
    • The GTIN field on the Google for WooCommerce tab
    • The field set via the attribute mapping rule created in step 2
  4. Go to wp-admin/admin.php?page=connection-test-admin-page and sync the product to Google
  5. View the product in Merchant Center and confirm the GTIN number matches the value entered in the Inventory tab
  6. Delete the GTIN value from the Inventory tab
  7. Re-sync the product and then confirm the value in Merchant Center now matches the value from the Google for WooCommerce tab
  8. Delete the GTIN value from the Google for WooCommerce tab
  9. Re-sync the product and then confirm the value in Merchant Center now matches the value from the attribute mapping rule

Changelog entry

Update - Product adapter to map GTIN value from WooCommerce core field if it's available

puntope commented 2 months ago

p.s I also tested with a non valid GTIN

Screenshot 2024-09-23 at 17 06 09