Handle fetching variations when duplicating variable products#10235
Handle fetching variations when duplicating variable products#10235
Conversation
| if (it.size > 100) { | ||
| // The API doesn't allow to create more than 100 variations at once | ||
| WooLog.w( | ||
| WooLog.T.PRODUCTS, "Variations list is too big: ${it.size}, " + | ||
| "the duplicate will have only the first 100 variations" | ||
| ) | ||
| } |
There was a problem hiding this comment.
The endpoint we use for the variations creation can handle only 100 items (https://woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-product-variations), while we can make multiple calls to handle the creation in this case, I think it's not worth it, as this should be a very rare case, WDYT?
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## trunk #10235 +/- ##
=========================================
Coverage 42.31% 42.31%
Complexity 4803 4803
=========================================
Files 977 977
Lines 54282 54293 +11
Branches 7170 7172 +2
=========================================
+ Hits 22969 22975 +6
- Misses 29306 29309 +3
- Partials 2007 2009 +2 ☔ View full report in Codecov by Sentry. |
Closes: #10232
Description
Currently, when trying to duplicate a variable product, we use try to duplicate just the list of cached variations, which causes two issues:
This PR adds logic to actually fetch variations before proceeding to duplicating them.
Testing instructions
Repeat also for a variable subscription.
RELEASE-NOTES.txtif necessary.