magento2: New bulk schedule doesn't create operations automatically
Preconditions (*)
- Magento 2.3.1
Steps to reproduce (*)
- Create a new bulk schedule
$bulkDescription = $this->getBulkMessage($order);
$bulkUuid = $this->identityService->generateId();
$data = ['just' => 'some dummy'];
$operationData = [
'data' => [
'bulk_uuid' => $bulkUuid,
'topic_name' => self::TOPIC_NAME,
'serialized_data' => $this->serializer->serialize($data),
'status' => \Magento\Framework\Bulk\OperationInterface::STATUS_TYPE_OPEN,
]
];
$operation = $this->operationsFactory->create($operationData);
$this->bulkManagement->scheduleBulk(
$bulkUuid,
[$operation],
$bulkDescription,
$this->userContext->getUserId()
);
In this scenario we add 1 operation to a bulk. The moment scheduleBulk
is called, a new record inside the magento_bulk
table is created.
Even with the queues up and running the operations are not created and stay “Pending”

I think the problem relies in the fact that the operation entities are never saved to the database.
Following function of class Magento\AsynchronousOperations\Model\BulkManagement
/**
* Publish list of operations to the corresponding message queues.
*
* @param array $operations
* @return void
*/
private function publishOperations(array $operations)
{
$operationsByTopics = [];
foreach ($operations as $operation) {
+ $this->entityManager->save($operation);
$operationsByTopics[$operation->getTopicName()][] = $operation;
}
foreach ($operationsByTopics as $topicName => $operations) {
$this->publisher->publish($topicName, $operations);
}
}
Adding this line $this->entityManager->save($operation);
in the publicOperations
function, resolves that problem for me.
Expected result (*)
- [Screenshots, logs or description]
- When a bulk is scheduled, the operations are created automatically
Actual result (*)
- [Screenshots, logs or description]
- When a bulk is scheduled, the operations are not created
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 30 (9 by maintainers)
Same here. Bulk edit has actually never worked. I’m following all issues but they all get closed without solution. I now fix these bulk edits by working with database queries but this should not be necessary. The suggested fix by @duckchip by adding the extra line in the publishOperations function did not change the result except it changed the bulk message from 1 in the queue to 0 in the queue.
i did it with deleting the entries in the
magento_bulk
table. Also facing this problem. Cannot bulk edit anything.@davidrthomson: make sure your
app/etc/env.php
file doesn’t have thecron_run
set tofalse
.Also: since you are using Magento 2.3.1, you shouldn’t have the
product_action_attribute.update
consumer, it was introduced in Magento 2.3.2, updating product attributes using queues was not available yet in 2.3.1 and should just work as is, so I’m a bit confused here… Runningbin/magento queue:consumers:list
should show which consumers you can use.If you are running Magento 2.3.2 or higher, make sure the
app/etc/env.php
file does not only have a couple ofconsumers
configured to run, if you leave thoseconsumers
empty, it should execute all of them. More info in the docs.Also, if you are talking about the default consumers Magento ships with which aren’t running automatically, then please follow https://github.com/magento/magento2/issues/23450 which contains some useful hints in various comments. This issue here was about implementing a custom bulk schedule by yourself in a custom module, so you are probably in the incorrect thread here.
Further update: I cannot reproduce this on clean 2.3.2 with sample data.
On my normal installation it occasionally works but usually it does not. When it works
magento_operations
is updated much later (probably upon processing the queue message?). I don’t know if that makes sense.I cannot figure out the conditions when it fails and logging is a bit slim. This is clearly something else. I will investigate further and open a new issue if I find something concrete
Ok guys, can anybody who has “this issue” please open a new ticket with exact steps to reproduce?
“This issue” here was created for writing your own custom bulk schedule jobs for which the documentation wasn’t very clear. It was closed by the author because the solution was found for this custom implementation.
“This issue” was not for running into default Magento bulk job problems. So if somebody can very clearly state in a new issue what steps you should perform to trigger this problem, that would be very much appreciated! 🙂