Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTIN] Add Migration support for YOAST SEO #2677

Open
wants to merge 1 commit into
base: add/support-core-gtin-field
Choose a base branch
from

Conversation

puntope
Copy link
Contributor

@puntope puntope commented Nov 18, 2024

Changes proposed in this Pull Request:

Closes #2665

This PR adds support for the YOAST GTIN field in the GTIN migration feature

Screenshots:

Screenshot 2024-11-18 at 11 33 19

Detailed test instructions:

  1. You need to have YOAST WooCommerce installed (notice the WooCommerce part, WordPress one doesn't have GTIN support)
  2. Set GTIN field for a simple product in Yoast SEO Tab
  3. Set GTIN field for a variation in Yoast SEO Tab (under the variations tab)
  4. Start the migration using the Connection test - Start GTIN Migration (be sure there is no other AS Job already running for GTIN migration)
  5. See the 2 products have the GTIN migrated
  6. Delete the GTINS for those products under Product Inventory (for the simple product) and from the variations tab for the variation.
  7. Start the migration using the WP CLI wp wc g4wc gtin-migration start --debug
  8. See the GTIN successfully migrated
  9. Run steo 7 again
  10. See logs about skipping the products.

Additional details:

Changelog entry

Add - Support YOAST SEO GTIN field in the migration tools.

@puntope puntope self-assigned this Nov 18, 2024
@puntope puntope requested a review from a team November 18, 2024 07:49
@github-actions github-actions bot added type: enhancement The issue is a request for an enhancement. changelog: add A new feature, function, or functionality was added. labels Nov 18, 2024
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 18 lines in your changes missing coverage. Please review.

Project coverage is 64.9%. Comparing base (b833f0c) to head (7da5ca2).
Report is 1 commits behind head on add/support-core-gtin-field.

Files with missing lines Patch % Lines
src/HelperTraits/GTINMigrationUtilities.php 11.1% 16 Missing ⚠️
src/Jobs/MigrateGTIN.php 0.0% 1 Missing ⚠️
src/Utility/WPCLIMigrationGTIN.php 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                       @@
##             add/support-core-gtin-field   #2677     +/-   ##
===============================================================
- Coverage                           64.9%   64.9%   -0.0%     
- Complexity                          4667    4671      +4     
===============================================================
  Files                                478     478             
  Lines                              19517   19527     +10     
===============================================================
  Hits                               12674   12674             
- Misses                              6843    6853     +10     
Flag Coverage Δ
php-unit-tests 64.9% <14.3%> (-<0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Integration/YoastWooCommerceSeo.php 81.2% <100.0%> (ø)
src/Jobs/MigrateGTIN.php 0.0% <0.0%> (ø)
src/Utility/WPCLIMigrationGTIN.php 0.0% <0.0%> (ø)
src/HelperTraits/GTINMigrationUtilities.php 21.6% <11.1%> (-8.0%) ⬇️

@puntope puntope marked this pull request as ready for review November 18, 2024 07:54
Copy link
Contributor

@mikkamp mikkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing the compatibility. I tested it and it does work as expected, however I think it would be nicer to keep the integration functionality encapsulated in the one class.

* @param WC_Product $product The product
* @return string|null
*/
protected function get_yoast_gtin( WC_Product $product ): ?string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure does work, but it wouldn't be my preferred choice, as it requires the migration to know details about Yoast compatibility as well as having access to public methods.

While we only added support for Yoast in theory there could be other plugins which add support for their structure. Which is why each class in the Integrations folder was implemented in such a way that in theory it could live both in the plugin and outside the plugin (maintained by a 3PD).

I think it would be better to keep it that way and add any necessary hooks so we don't need to make parts of the Yoast integration classes public.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just add a filter in get_gtin so we don't need to add anything in regards to Yoast here. Then in the class YoastWooCommerceSeo we can hook into the filter for migration and if it has a value to return it can do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants