-
Notifications
You must be signed in to change notification settings - Fork 25
Add all combination endpoints #102
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
base: dev
Are you sure you want to change the base?
Conversation
|
nice PR ! whaou ! 15 endpoints |
|
Hello @Jeremie-Kiwik Thank you for this PR. There are a few errors in the integration tests, looks like some typos in the paths, could you take a look? |
|
@kpodemski : ah sorry, I thought those were internal errors in the deployment of the test environments. I didn’t really look into it any further. |
|
@Jeremie-Kiwik there is a conflict on your PR. |
10aba8c to
707d1e7
Compare
b23ee33 to
7aefe3d
Compare
|
Hello @Jeremie-Kiwik Thanks for fixing the conflicts, the last step is making sure to have the CI 🟢. Thank you 🙏🏻 |
|
Hello @Jeremie-Kiwik Just a quick heads-up: reviews on pending Admin API PRs will start in the coming days. We first took some time to clarify and unify the Admin API contribution rules and ADR expectations. With that work done, the team will now review existing PRs based on those updates. Please note that, based on the updated standards described here: some aspects of this PR currently do not meet the requirements. For this reason, I've added the Invalid label for now. Someone from the team will take a closer look at the PR and provide concrete suggestions on how it can be adjusted to align with the new guidelines. Thanks for your patience. Feedback will follow directly on the PR. |
|
Hi, |
EDIT
Changed endpoints to match the new ADR convention
#109
Endpoints summary
GET /products/combinations/{combinationId}
PATCH /products/combinations/{combinationId}
DELETE /products/combinations/{combinationId}
POST /products/{productId}/combinations
GET /products/{productId}/combinations/ids
GET /products/{productId}/combinations
DELETE /products/{productId}/combinations/bulk-delete
PATCH /products/combinations/{combinationId}/stocks
GET /products/combinations/{combinationId}/stock-movements
PATCH /products/combinations/{combinationId}/suppliers
GET /products/combinations/{combinationId}/suppliers
PATCH /products/combinations/{combinationId}/images
PATCH /products/combinations/{combinationId}/images/clears
GET /products/{productId}/combinations/search
GET /products/combinations/associations/search
How to test
Create an API Client with these scopes:
product_read&product_writeRequest an access token
0. Create a product
POST/admin-api/products{ "productType": "combinations", "names": { "fr-FR": "Test combinated product" } }Get the product ID in the response. We will use it as
{productId}for other calls1. Generate product combinations
(
GenerateProductCombinationsCommandcommand)Will add 4 combinations, with:
attribute group 'Size' (
id_attribute_group=1)id_attribute=2)id_attribute=3)attribute group 'Color' (
id_attribute_group=2)id_attribute=10)id_attribute=14)Method:
POSTURI:
/admin-api/products/{productId}/combinationsBody:
{ "groupedAttributeIds": { "1": [2, 3], "2": [10, 14] } }HTTP Code:
201HTTP Body: object with
combinationscontaining 4 combinations, andtotalCombinationsCountPlease note the 4
combinationId, we will use them below. Let's call them{combinationId_1}, ...,{combinationId_4}, in ascending order.You should see the combinations in back office too.
2. Get combinations IDs
(
GetCombinationIdscommand)GET/admin-api/products/{productId}/combinations/idsHTTP Code:
200HTTP Body: array of
{ "combinationId": number }with our 4 Ids3. Update a combination
(
UpdateCombinationCommandcommand)PATCH/admin-api/products/combinations/{combinationId_1}{ "isDefault": true, "reference": "REF-001", "gtin": "3519690900332", "isbn": "978-3-16-148410-0", "mpn": "MPN-123", "upc": "72527273070", "impactOnWeight": 0.15, "impactOnPrice": 1.99, "ecoTax": 0.2, "impactOnUnitPrice": 0.3, "wholesalePrice": 12.5, "minimalQuantity": 2, "lowStockThreshold": 5, "availableDate": "2025-12-31T00:00:00+00:00", "availableNowLabels": { "fr-FR": "En stock", "en-GB": "In stock" }, "availableLaterLabels": { "fr-FR": "Bientôt", "en-GB": "Later" } }HTTP Code:
200HTTP Body: updated combination
4. Get all combinations detail
(
GetEditableCombinationsListcommand)GET/admin-api/products/{productId}/combinationsHTTP Code:
200HTTP Body:
{ productId, combinations: [...], totalCombinationsCount }5. Get single combination detail
(
GetCombinationForEditingcommand)GET/admin-api/products/combinations/{combinationId_1}HTTP Code:
200HTTP Body: full combination details (pricing, labels, dates, identifiers)
6. Delete a single combination
(
DeleteCombinationCommandcommand)Let's delete the 'L - size' / 'Red - color' combination:
DELETE/admin-api/products/combinations/{combinationId_3}HTTP Code:
204HTTP Body: none
7. Bulk delete combinations
(
BulkDeleteCombinationCommandcommand)Let's delete now all the blue combinations:
(change {combinationId_x} in the body with real values)
PUT/admin-api/products/{productId}/combinations/bulk-delete{ "combinationIds": [{combinationId_2}, {combinationId_4}] }HTTP Code:
204HTTP Body: none
8. Update combination stock
(
UpdateCombinationStockAvailableCommandcommand)Fixed quantity
PATCH/admin-api/products/combinations/{combinationId_1}/stocks{ "location": "somewhere", "fixedQuantity": 42 }HTTP Code:
200HTTP Body: updated combination id, with updated quantity + location
HTTP Code:
422On back-office, you should see a quantity of
42for the combination.Delta quantity
PATCH/admin-api/products/combinations/{combinationId_1}/stocks{ "deltaQuantity": -10 }Same as fixed quantity
On back-office, you should see a quantity of
32for the combination.9. Get stock movements
(
GetCombinationStockMovementscommand)GET/admin-api/products/combinations/{combinationId_1}/stock-movements?limit=5HTTP Code:
200HTTP Body: array of movements (type, dates, ids, deltaQuantity, employeeName)
10. Update suppliers for a combination
(
UpdateCombinationSuppliersCommandcommand)Before testing, suppliers must be linked to the product.
The endpoint to associate suppliers with a product has not been implemented yet. It must be done manually from the back office:
0)Here we go: update information.
PATCH/admin-api/products/combinations/{combinationId_1}/suppliers{ "combinationSuppliers": [ { "supplier_id": 1, "currency_id": 1, "reference": "SUP-REF-001", "price_tax_excluded": "10.50" }, { "supplier_id": 2, "currency_id": 1, "reference": "SUP-REF-002", "price_tax_excluded": "20.00" } ] }HTTP Code:
200HTTP Body: updated suppliers list for the combination
11. Get suppliers associated to a combination
(
GetCombinationSupplierscommand)GET/admin-api/products/combinations/{combinationId_1}/suppliersHTTP Code:
200HTTP Body: array of suppliers (productSupplierId, productId, supplierId, supplierName, reference, priceTaxExcluded, currencyId, combinationId)
12. Associate images to a combination
(
SetCombinationImagesCommandcommand)First add 3 random images to the product
{productId}, on the back office. We will then add 2 of them to the combinationGet the associated
id_imagein DB. We will use them as{imageId_1},{imageId_2}and{imageId_3}.If you don't have access to the DB, reload the page then inspect the DOM of the image to get the data-id
You will have something like:
Your id is
27PATCH/admin-api/products/combinations/{combinationId_1}/images(replace
{imageId_x}with the real values){ "imageIds": [{imageId_1}, {imageId_3}] }HTTP Code:
200HTTP Body: updated combination (at least combinationId, imageIds)
On back-office, you should see that 2 images are linked to the combination (with a black border around the images)
13. Remove all images from a combination
(
RemoveAllCombinationImagesCommandcommand)PATCH/admin-api/products/combinations/{combinationId}/images/clearsHTTP Code:
200HTTP Body: updated combination (at least combinationId)
On back-office, images are no more linked to the combination (no black border around them)
14. Search combinations (scoped to a product)
(
SearchProductCombinationscommand)Will search combinations with for example, a given string in attributes
GET/admin-api/products/{productId}/combinations/search?phrase=rouge&limit=5Note: The search strings are localized. So if you have an English PS, please test
search?phrase=redinstead, like this:/admin-api/product/{productId}/combinations/search?phrase=red&limit=5HTTP Code:
200HTTP Body:
{ "productId": {productId}, "combinations": [ { "combinationId": x, "combinationName": "xxxx" } ] }If you search for a non-existent string,
combinationsshould be empty.15. Search combinations for association (global search)
(
SearchCombinationsForAssociationcommand)Important note: this search DOES NOT search in attribute names; it searches product/combination name and references (like ref, ean13, upc, mpn, isbn, supplier_reference...)
GET/admin-api/products/combinations/associations/search?phrase=REF&limit=5HTTP Code:
200HTTP Body: array of
{ productId, combinationId, name, reference, imageUrl }Or an empty array if nothing is found