Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill data_hash from BULK response with correct data #21815

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/code/Magento/AsynchronousOperations/Model/MassSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Psr\Log\LoggerInterface;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Framework\Encryption\Encryptor;

/**
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking
Expand Down Expand Up @@ -63,6 +64,11 @@ class MassSchedule
*/
private $userContext;

/**
* @var Encryptor
*/
private $encryptor;

/**
* Initialize dependencies.
*
Expand All @@ -73,6 +79,7 @@ class MassSchedule
* @param LoggerInterface $logger
* @param OperationRepository $operationRepository
* @param UserContextInterface $userContext
* @param Encryptor|null $encryptor
*/
public function __construct(
IdentityGeneratorInterface $identityService,
Expand All @@ -81,7 +88,8 @@ public function __construct(
BulkManagementInterface $bulkManagement,
LoggerInterface $logger,
OperationRepository $operationRepository,
UserContextInterface $userContext = null
UserContextInterface $userContext = null,
Encryptor $encryptor = null
) {
$this->identityService = $identityService;
$this->itemStatusInterfaceFactory = $itemStatusInterfaceFactory;
Expand All @@ -90,6 +98,7 @@ public function __construct(
$this->logger = $logger;
$this->operationRepository = $operationRepository;
$this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class);
$this->encryptor = $encryptor ?: ObjectManager::getInstance()->get(Encryptor::class);
}

/**
Expand Down Expand Up @@ -130,9 +139,11 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
$requestItem = $this->itemStatusInterfaceFactory->create();

try {
$operations[] = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
$operation = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
$operations[] = $operation;
$requestItem->setId($key);
$requestItem->setStatus(ItemStatusInterface::STATUS_ACCEPTED);
$requestItem->setDataHash($this->encryptor->hash($operation->getSerializedData(), Encryptor::HASH_VERSION_SHA256));
$requestItems[] = $requestItem;
} catch (\Exception $exception) {
$this->logger->error($exception);
Expand Down