Table of contents
Bulk actions not starting used to be a common issue on Magento 2.3.x and lower versions. And while there’s a fix for this bug in Magento development branches, it still requires a bit of manual work to implement the fix into your Magento store.
In this article, we will be digging into this bug and offer you solutions to help you deal with this issue:
Steps to reproduce
This actually is an easily reproducible bug, which is part of the reason why it’s so popular.
- In your Magento 2 Admin, go to Catalog > Products
2. Select All Products and in Actions, choose Update attributes
3. Update a product attribute. For demonstration purposes, we’ll be updating product descriptions.
4. Click on Save and you’ll see that, despite selecting several products, 0 item has been scheduled for update.
And when you check Bulk Actions Log (in System > Action Logs > Bulk Actions), it’ll show that the bulk action jobs we previously apply are not started:
Further clicking on Details and you’ll see that our bulk actions seem to be stuck in the “Pending, in queue…” mode.
Solutions
There are several ways using which you can get around this bug. Here are several methods to try if the bug is resolved for you.
For Magento 2.4.x and above
For Magento 2.4.x and above, there’s a fix on Magento development branches which requires you to go into:
<Magento_dir>vendor/magento/module-asynchronous-operations/etc/
In this folder, you’ll want to edit db_schema.xml
(remember to make a backup of the file first). In this file, go to line 37:
<column xsi:type="int" name="operation_key" padding="10" unsigned="true" nullable="false"
And change nullable="false"
to nullable="true"
. After which, run:
php bin/magento s:up
This should resolve the issue for your newer bulk action jobs (previously stuck bulk action jobs will still remain stuck). To unstuck your previous cron action jobs, manually run your cron jobs by executing:
php bin/magento cron:run
For Magento 2.3.x and below
For earlier Magento versions (Magento 2.3.x and below), you’ll want to do things in a different way, and there are several ways to do this.
1. Manually run a cron job
The most popular solution for this issue is to manually run a cron job.
php bin/magento cron:run
Or make sure that cron is running properly:
crontab -u <Magento file system owner name> -l
If no crontab has been setup, you’ll see the following messages:
no crontab for magento_user
Your crontab tells you the following:
- What PHP binary you’re using (in some cases, you have more than one)
- What Magento cron scripts you’re running (in particular, the paths to those scripts)
- Where your cron logs are located
After running a cron job, you’ll see that your previous stuck action jobs are finished successfully.
2. Make changes to cron_consumers_runner
in env.php
If the above solution doesn’t work for you, you can try editing the env.php
file. In this file, look for cron_consumers_runner
and replace its content with the following code:
'cron_consumers_runner' => [ 'cron_run' => true, 'max_messages' => 2000, 'consumers' => [ 'product_action_attribute.update', 'product_action_attribute.website.update', 'exportProcessor', 'codegeneratorProcessor' ] ]
If you are not able to find a cron_consumers_runner
function in the file, just insert it to the bottom of env.php
, like so:
Conclusion
We hope that this article brings you the fix that you need to resolve this issue. If none of the listed solutions works for you, do feel free to let us know in the comment section below so we can work on bringing you better solutions.