Syncing carts + orders + promotions need refactoring
Opened this issue · 1 comments
jlachancekffein commented
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]])
);
}
peteeveleigh commented
As per this issue from May 2020 #30