[WOOMOB-3586] Use WooCommerce's product duplication endpoint#16262
[WOOMOB-3586] Use WooCommerce's product duplication endpoint#16262hichamboushaba wants to merge 3 commits into
Conversation
|
|
3c52976 to
18012d1
Compare
There was a problem hiding this comment.
AI Code Review - No issues found. The changes look good.
The PR adds server-side product duplication (POST /wc/v3/products/<id>/duplicate) with a safe fallback to the existing client-side flow when the route is missing on older stores. The layering (REST client -> store -> repository -> use case) is clean, error/edge cases (missing/zero/negative IDs, non-route errors) are guarded, and the change is well covered by unit tests at every layer. I traced the endpoint path generation and confirmed the trailing slash is normalized by EndpointTreeGenerator, so the generated pathV3 matches the asserted /wc/v3/products/123/duplicate/.
PR housekeeping
- Nit: in
wc-wp-api-endpoints.txtthe new/products/<id>/duplicateentry omits the trailing slash that its neighbours use (availability/,variations/). Functionally irrelevant (the processor normalizes it), but adding the slash keeps the file consistent. - Applied repo
AGENTS.md/CLAUDE.mdguidance while reviewing (Store Management data-layer patterns, FluxC store/repository conventions).
Automatic review · claude-opus-4-8 · Workflow run
How to reply to a finding
Reply on this review (or inline at the line the finding refers to) with one of:
@claude addressed- I made the change. Bot verifies against the next diff before marking resolved.@claude rejected: <reason>- Will not fix; reason gets quoted on the next review.@claude not-applicable- Finding does not apply (wrong file, already covered elsewhere, etc.).
The bot honours these on the next review pass.

Description
Fixes WOOMOB-3586
Android now calls WooCommerce Core's server-side product duplicate endpoint so duplicated products preserve the data managed by WooCommerce. The existing client-side implementation remains as a compatibility fallback only when the endpoint is conclusively absent: the error must be
API_NOT_FOUNDwith therest_no_routeAPI code.Other or ambiguous errors remain terminal. Product duplication is non-idempotent, so retrying with the local implementation after an uncertain server response could create two products.
The network response intentionally maps only the duplicated product ID. WooCommerce Core returns raw product data from this endpoint rather than the canonical REST product representation, and the destination product screen performs the normal canonical fetch and cache flow.
ProductDetailRepositoryexposes the operation as KotlinResult<Long>. The existing progress dialog, destination navigation, and analytics behavior remain unchanged.Test Steps
(Copy)suffix, and all of the listed product fields load.POST /wc/v3/products/<source-id>/duplicate, status 404, and this response body:{"code":"rest_no_route","message":"No route was found matching the URL and request method.","data":{"status":404}}/duplicateendpoint match followed by one legacyADD_PRODUCTrequest, the app opens one new Draft, and no second duplicate is created.{"code":"woocommerce_rest_product_invalid_id","message":"Invalid product ID.","data":{"status":404}}ADD_PRODUCTrequest.Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.