Add GetShopProductImages Admin API endpoint - #354
PrestaEdit wants to merge 5 commits into
Conversation
Adds GET /products/{productId}/shop-images using CQRSGetCollection with
GetShopProductImages. Response is a per-shop list of {shopId, productImages[]}
where each productImages entry is {imageId, cover}.
Related to PrestaShop/PrestaShop#39630
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The CQRSGetCollection endpoint has a URI placeholder {productId} that is
NOT the item identifier — items are per-shop rows without a stable IRI.
Setting identifier: true on shopId made ApiPlatform's ReadListener try to
resolve an item by IRI and fail with NotFoundHttpException
'Invalid identifier value or configuration'. Precedent: ProductImageList
also has no identifier annotation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The handler does not validate product existence — unknown product ids return an empty collection with HTTP 200, not a 404. Drop the incorrect 404 assertion and the unused ProductNotFoundException exception mapping. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📋 Summary of changesAdds a new ⏱️ Estimated review time10–15 minutes — the diff is small but several conventions from the analogous 🎯 Scope
🧱 API Platform / CQRS architecture compliance1. Missing
|
|
Synthesis on top of the AI pre-review 👇 Overstated / false positives:
One real decision: this endpoint behaves differently from its sibling Worth doing (test): assert the nested |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks for strengthening the test 👍 but the new fixture query broke CI on every integration leg: The |
Db::getValue() appends its own LIMIT 1, so the explicit LIMIT 1 in the SQL produced 'LIMIT 1 LIMIT 1' and failed every CI integration leg with a PrestaShopDatabaseException syntax error. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mattgoud
left a comment
There was a problem hiding this comment.
LGTM ✅ verified the wiring against core: GetShopProductImages returns the per-shop {imageId, cover} grouping, unknown product → empty 200 [] (no exception, so no exceptionToStatus needed), and it's intentionally all-shops so no shopConstraint mapping. the test asserts the full contract against the image_shop fixture.
non-blocking nit: if the test fixture has more than one shop, a quick assertion that the grouping actually spans multiple shops would nail down the endpoint's whole point — but the grouping logic itself lives in core, so fine to merge as-is.
|
Closing in favor of #410, which centralizes all the pending Product-domain endpoints into a single PR: mutualizing the changes makes the review simpler, and it allowed rebuilding the integration tests so that every fixture is created through the API alone (with whole-structure assertions). @PrestaEdit your work is kept and you are co-authored on the commits of #410 — thanks! Note: in #410 the endpoint returns a single resource shared with the write operation: {productId, shopImages: [{shopId, images: [{imageId, cover}]}]}. |
Centralizes the pending Product-domain endpoint PRs into a single branch, as requested in PrestaShop/PrestaShop#42054 (tracking table: PrestaShop/PrestaShop#39630). Original content authored by PrestaEdit: - PrestaShop#337 GET product attribute groups - PrestaShop#353 GET product supplier options - PrestaShop#354 GET shop product images - PrestaShop#361 GET product stock movements - PrestaShop#374 GET free gift candidates - PrestaShop#383 POST/PATCH virtual product file - PrestaShop#384 PUT product image shop associations - PrestaShop#256 PUT product stock - PrestaShop#268 product suppliers (associate, default, remove all) - PrestaShop#269 PATCH product supplier details - PrestaShop#308 DELETE virtual product file (resource only; its test file collides with PrestaShop#383's and the tests are rewritten in this PR) Endpoints are imported as-is; consolidation, review fixes and test rewrites follow in dedicated commits. Co-Authored-By: Jonathan Danse <j.danse@prestaedit.com>
Centralizes the pending Product-domain endpoint PRs into a single branch, as requested in PrestaShop/PrestaShop#42054 (tracking table: PrestaShop/PrestaShop#39630). Original content authored by PrestaEdit: - PrestaShop#337 GET product attribute groups - PrestaShop#353 GET product supplier options - PrestaShop#354 GET shop product images - PrestaShop#361 GET product stock movements - PrestaShop#374 GET free gift candidates - PrestaShop#383 POST/PATCH virtual product file - PrestaShop#384 PUT product image shop associations - PrestaShop#256 PUT product stock - PrestaShop#268 product suppliers (associate, default, remove all) - PrestaShop#269 PATCH product supplier details - PrestaShop#308 DELETE virtual product file (resource only; its test file collides with PrestaShop#383's and the tests are rewritten in this PR) Endpoints are imported as-is; consolidation, review fixes and test rewrites follow in dedicated commits. Co-Authored-By: Jonathan Danse <j.danse@prestaedit.com>
GET /products/{productId}/shop-imagesusingCQRSGetCollectionwithGetShopProductImages. Returns per-shop image associations: each element ={shopId, productImages: [{imageId, cover}, ...]}. Complements the existingGET /products/{productId}/images(ProductImageList, single-shop) with the multi-shop view. Unknown product id returns200 [](no exception), matching the underlying all-shops query.composer phpunit-integration;ShopProductImagesEndpointTestcovers scope protection and the list happy path, asserting the exact per-shop{imageId, cover}grouping against the fixture data (image_shoptable).