What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Can anybody help me with conditions in the statemachine? My Condition test does not work and I have

UKTEVG9L4
UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

Can anybody help me with conditions in the statemachine?

My Condition test does not work and I have no clue why?
I'm runing the spryker b2c demo shop on docker.
My statemachine code for the condition looks like:

<transition condition="Oms/CheckInvoiceAmount" happy="true">
    <source>release</source>
    <target>payment pending</target>
    <event>check amount</event>
</transition>

<transition condition="Oms/CheckInvoiceAmount" happy="true">
    <source>release</source>
    <target>release order</target>
    <event>check amount</event>
</transition>

And the condition class check function:

return $orderItem->getGrossPrice() > 500 ? true : false;

The result of the condition check always ends in the "release order" state.

Any suggestions?

Comments

  • Unknown
    edited February 2020

    Hello Robert! You have 2 transitions with happy=true. Probably this is the issue

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yes I know that. But changing this and having only one happy path is not the solution

  • Yes that should not matter πŸ€”

  • Why are there two transitions from the same state under the same condition?

  • There can always only be one result. And the order then comes down to implementation details

  • I think this should be conceptually different

  • Can you elaborate on the scenario?

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thanks Marco for your help. Maybe there is the error in my concept. I'll give it a try.

  • Still interested in what you found πŸ˜‰

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UJN2JRU4F - Is there a log output for transitions and state changes in spryker?

  • There is in the database. Also for the oms state machine it is displayed next to the order items in zed

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    I know the current state for the order in the sales tab.

    I'll have a look at the database.

    Maybe my condition is "always" true.

  • Just to satisfy my ocd I have to remark that
    ? true : false
    is always redundant

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    Any suggestions for debugging / logging the check function ?

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ok solved the problem!

  • Good to hear! You can always share you solution to help other with the same problem πŸ™‚

  • scheduler off, console command + xdebug would be the easiest way

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet
    1. @UJN2JRU4F solution with writing the condition in ust one transition
    2. the gross price of the order item is an integer. πŸ˜…
  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet

    Now my last problem is to check this condition for the whole order not the item level.

    Example:

    Order total is above X then got to this state

  • \Spryker\Zed\Sales\Business\SalesFacade::findOrderByIdSalesOrderItem might help you

  • UKTEVG9L4
    UKTEVG9L4 Posts: 38 πŸ§‘πŸ»β€πŸš€ - Cadet
    $orderItem->getOrder()->getLastOrderTotals()->getGrandTotal()
    

    Is the total of the order!