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

  • Creator
  • #28495


    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 =')
    ->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
  • #28496

    Yevhen Shyshkin

    Hello, Dmitri.

    Performance issue happens because of flush on each transition (see 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)

You must be logged in to reply to this topic.