-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
This issue is automatically created based on existing pull request: #40237: Allow some SalesSequence data to be retrieved by extensions for customisatioons
Description (*)
Being able to change the sequence generation for a specific entity type is a reasonably common request. The objective of this PR is to allow extensions to more easily modify this: currently, it is impossible without overriding the whole model (read: copy and paste, since everything is private).
This PR will allow extensions or vendors to change the format, for instance with an after plugin:
public function afterGetNextValue(
\Magento\SalesSequence\Model\Sequence $subject,
string $result
) {
//If we're generating for an order, set its sequence to ECOM{STORE_ID}#{4 DIGIT INC. ID}
if ('order' === $subject->getEntityType()) {
return \sprintf('ECOM%d#%\'.04d', $subject->getStoreId(), $subject->calculateCurrentValue());
}
//Otherwise, passthrough
return $result;
}NB: this would probably be a good use case for some sort of expansion (having some di-defined array for entity types to calculate their values), but this is a good first step IMO.
Related Pull Requests
N/A
Fixed Issues (if relevant)
N/A
Manual testing scenarios (*)
This is a transparent API change: it should not change anything. Perhaps trying an after plugin like mentioned above.
Questions or comments
Unsure re: unit tests. I've added some, but they seem superfluous.
Contribution checklist (*)
- Pull request has a meaningful description of its purpose
- All commits are accompanied by meaningful commit messages
- All new or changed code is covered with unit/integration tests (if applicable)
- README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- All automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status