Question About Command and Condition Execution Order in Merchant Portal State Machine

Hi everyone,
I'm currently working on a state machine for the Merchant Portal in Spryker. I’ve defined a transition from state A to B, and in this transition, I’ve attached both a condition and a command.
After debugging the flow, I noticed that the command is being executed before the condition, which is problematic in my case. The reason is that the command is triggering OMS events, and I only want that to happen if the condition passes.
My question is:
Is there a way to enforce the state machine to evaluate the condition before executing the command?
Or is there an established best practice in Spryker to handle this kind of flow?
Any insights, suggestions, or workarounds would be really appreciated!
Thanks in advance!
Answers
-
The normal workflow is:
1) An OMS event is triggered2) If there is a command, the command is executed, and that command can set something up for the condition to verify
3) The transition is executed. If there is a condition, then the condition is verified for the transition to happen
This is the way it works, so you should adapt your logic to these steps.Why should the command trigger an OMS event? The command could just set some value so that the transition you want to happen be executed . Commands shouldn't trigger OMS events as It could create a recursion issue as commands are executed by events
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 84 Spryker News
- 984 Developer Corner
- 835 Spryker Development
- 92 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 36 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 32 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 33 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random