Merge the two OrderState resource PRs into one - #417
Open
PrestaEdit wants to merge 5 commits into
Open
PrestaEdit wants to merge 5 commits into
PrestaEdit wants to merge 5 commits into
Conversation
Add the Admin API endpoints for the OrderState domain (order statuses):
- POST /order-states (AddOrderStateCommand)
- GET /order-states/{orderStateId} (GetOrderStateForEditing)
- PATCH /order-states/{orderStateId} (EditOrderStateCommand)
- DELETE /order-states/{orderStateId} (DeleteOrderStateCommand)
- DELETE /order-states/bulk-delete (BulkDeleteOrderStateCommand)
Exposes the order state data fields (localized names + email templates, color
and the behaviour flags: loggable, invoice, hidden, sendEmail, pdfInvoice,
pdfDelivery, shipped, paid, delivery). As with Contact/OrderReturnState the
create and update commands expect different field names (localizedNames/
localizedTemplates vs name/template), handled by distinct command mappings.
The optional state icon upload is intentionally left out of this first version.
Adds an integration test covering the full CRUD + bulk delete, and the
order_state_read / order_state_write scopes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two issues from the first version: - GetOrderStateForEditing exposes isSendEmailEnabled() and isDeleted(), so the query result keys are "sendEmailEnabled" / "deleted" — added the missing mappings to QUERY_MAPPING and an "isDeleted" property to the resource. - Order states are soft-deleted, so the record is still readable after a delete; the tests now assert isDeleted=true instead of a 404. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rector's boolean property naming rule requires 'deleted' rather than 'isDeleted'; with that name the query result field maps by identity, so the extra QUERY_MAPPING entry is dropped. Tests updated accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Consolidates PrestaShop#226 and PrestaShop#260, which both created src/ApiPlatform/Resources/OrderState/OrderState.php and tests/Integration/ApiPlatform/OrderStateEndpointTest.php with different content. Takes PrestaShop#260 as the base (it is the more complete one) and grafts what only PrestaShop#226 had: - PrestaShop#260 wins on: POST replaying GetOrderStateForEditing so the create returns the entity, the DefaultLanguage constraints on the localized names, the DuplicateOrderStateNameException mapping and the paginated list endpoint - PrestaShop#226 wins on: the read-only "deleted" property (EditableOrderState::isDeleted()), skip_null_values => false, read: false on the partial update, and the soft-delete assertions its test had and PrestaShop#260's had lost - one bulk class instead of BulkDeleteOrderState + BulkDeleteOrderStates, and its exception mapping is fixed: the handler swallows every OrderStateException and rethrows BulkDeleteOrderStateException with the failed ids, so neither OrderStateNotFoundException => 404 (PrestaShop#226) nor OrderStateException => 404 (PrestaShop#260) could ever fire. It is now BulkDeleteOrderStateException => 422 - the create, get and update assertions compare the complete entity instead of checking a few keys, so a missing or extra field fails the test Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 20, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Merges #226 and #260 into one PR, following the mutualisation done on the Product domain in #410.
These two PRs were not complementary — they were two different implementations of the same resource. Both created
src/ApiPlatform/Resources/OrderState/OrderState.phpandtests/Integration/ApiPlatform/OrderStateEndpointTest.php, plus a bulk-delete class differing only by its name (BulkDeleteOrderStatevsBulkDeleteOrderStates). Whichever had been merged first, the other would have conflicted.Endpoints
/order-states/{orderStateId}GetOrderStateForEditingorder_state_read/order-statesprestashop.core.grid.data_provider.order_statesorder_state_read/order-statesAddOrderStateCommand+GetOrderStateForEditingorder_state_write/order-states/{orderStateId}EditOrderStateCommand+GetOrderStateForEditingorder_state_write/order-states/{orderStateId}DeleteOrderStateCommandorder_state_write/order-states/bulk-deleteBulkDeleteOrderStateCommandorder_state_writeHow the two versions were reconciled
#260is the base, since it was the more advanced of the two. What#226had and#260did not has been grafted back in:POSTreplayingGetOrderStateForEditing, so the create returns the entity instead of just{orderStateId}DefaultLanguageconstraints onnames(the core validator for localized required fields) rather than a plainNotBlankDuplicateOrderStateNameException→422OrderStateList)deletedproperty —EditableOrderState::isDeleted()was exposed by neither the resource nor the tests in #260normalizationContext: ['skip_null_values' => false]read: falseon the partial update, consistent with the other resources declaring aCQRSQueryFixed along the way
The bulk-delete exception mapping was wrong in both PRs.
BulkDeleteOrderStateHandlercatches everyOrderStateException(including "not found") per id, collects the failures and rethrows a singleBulkDeleteOrderStateException. SoOrderStateNotFoundException => 404(#226) could never fire, andOrderStateException => 404(#260) turned a partial failure into a 404. It is nowBulkDeleteOrderStateException => 422.BulkDeleteOrderStateExceptiondoes not implementBulkCommandExceptionInterface, so the multi-status normalizer does not apply here and a plainexceptionToStatusmapping is the right thing.Tests
One
OrderStateEndpointTestinstead of the two conflicting ones. It already built every fixture through the API in #260; what changed:testAddOrderState,testGetOrderStateandtestPartialUpdateOrderStatenow compare the complete entity with a singleassertEqualsinstead of checking a handful of keys, which is what actually pins the read/write symmetry of thePOSTand thePATCH;GETwithdeleted: true, and no longer appears in the listing. Add OrderState Admin API endpoints (CRUD + list + bulk delete) #260's test only checked the listing.How to test
Covered by
OrderStateEndpointTest.Supersedes
Both will be closed once the CI is green here.