Skip to content

Commit

Permalink
ENGCOM-4531: Fill data_hash from BULK response with correct data #21815
Browse files Browse the repository at this point in the history
  • Loading branch information
sidolov authored Mar 22, 2019
2 parents 20a3619 + 4e13e66 commit cbbca83
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 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,13 @@ 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

0 comments on commit cbbca83

Please sign in to comment.