Skip to content

New bulk schedule doesn't create operations automatically #23958

@duckchip

Description

@duckchip

Preconditions (*)

  1. Magento 2.3.1

Steps to reproduce (*)

  1. 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"

Screen Shot 2019-07-31 at 09 59 05

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 (*)

  1. [Screenshots, logs or description]
  2. When a bulk is scheduled, the operations are created automatically

Actual result (*)

  1. [Screenshots, logs or description]
  2. When a bulk is scheduled, the operations are not created

Metadata

Metadata

Assignees

Labels

Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions