OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

This topic contains 3 replies, has 2 voices, and was last updated by  Yevhen Shyshkin 6 years, 11 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #33976


    Hello, I want to automation workflow to send email, etc.

    I create a command but I have a performance problem.

    /** @var \Doctrine\ORM\EntityManager $em */
    $em = $this->getContainer()->get('doctrine.orm.entity_manager');

    $workflowItems = $em->createQueryBuilder()
    ->from('OroWorkflowBundle:WorkflowItem', 'wi')
    ->from('OroWorkflowBundle:WorkflowStep', 'ws')
    ->where('wi.currentStep = ws.id')
    ->andWhere('wi.definition = \'main_workflow\'')

    $user = $this->getContainer()->get('doctrine')->getRepository('OroUserBundle:User')->findOneBy(['username' => 'admin']);
    $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());

    $workflowManager = $this->getWorkflowManager();

    foreach ($workflowItems as $workflowItem)
    $transitions = $workflowManager->getTransitionsByWorkflowItem($workflowItem);

    foreach ($transitions as $transition) {
    if($workflowManager->isTransitionAvailable($workflowItem, $transition)) {
    $workflowManager->transit($workflowItem, $transition);

    Have you an idea to update a code ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #33977

    Yevhen Shyshkin

    Hello, Dmitri.

    Performance issue happens because of flush on each transition (see https://github.com/laboro/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Model/WorkflowManager.php#L167). We’ve already fixed this issue for mass start of workflow (see methods startWorkflow and massStartWorkflow) – looks like now we need to do the same for transit method. We will do that ASAP.

    If I understand conditions correctly, your workflow items does not have cross relations, so you can safely perform all transits in one flush and transaction. I’d recommend you to create some service and implement mass transit logic there. Also it would be really good if you add massTransit action to WorkflowManager and create pull request to platform – so we can merge it and it will be available in the next release.

    Feel free to post here PR or any questions related to this issue.



    Thank’s for your answer.
    I did a pull request which implement a method massTransitWorkflow.
    I was inspired of method massStartWorkflow as you have suggested me.


    Yevhen Shyshkin

    Thank you!

    We’ll review and merge it ASAP.

Viewing 3 replies - 1 through 3 (of 3 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No