Skip to content

Syncing carts + orders + promotions need refactoring #36

@jlachancekffein

Description

@jlachancekffein

The way it's done right now, it is impossible to synchronize resources when there is a high count.

The problem is, the queue has to process all the elements at once.

To adjust locally, I added one item at a time to the queue. For example, if there are 2000 orders to synchronize, I add 2000 queue jobs for processing all the orders.

That way, no matter how many items you need to process, I'm sure the job won't crash.

Here is an example of one of the controller actions :

$ordersIds = Order::find()->isCompleted(true)->ids();
foreach ($ordersIds as $ordersId) {
   Craft::$app->getQueue()->push(
      new SyncOrders(['orderIds' => [$ordersId]])
   );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions