Skip to content

Commit

Permalink
Add current loggedin admin user ID to bulk publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
supercid committed Jun 28, 2024
1 parent 83c1388 commit be315e7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Model/Service/Sync/AbstractBulkPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Magento\Framework\Module\Manager;
use Magento\Framework\Serialize\SerializerInterface;
use Nosto\Tagging\Logger\Logger;
use Magento\Backend\Model\Auth\Session;
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;

abstract class AbstractBulkPublisher implements BulkPublisherInterface
Expand Down Expand Up @@ -81,12 +82,14 @@ public function __construct(// @codingStandardsIgnoreLine
OperationInterfaceFactory $operationInterfaceFactory,
SerializerInterface $serializer,
Manager $manager,
Session $authSession,
Logger $logger
) {
$this->identityService = $identityService;
$this->operationFactory = $operationInterfaceFactory;
$this->serializer = $serializer;
$this->manager = $manager;
$this->authSession = $authSession;

Check warning on line 92 in Model/Service/Sync/AbstractBulkPublisher.php

View workflow job for this annotation

GitHub Actions / Phan Analysis

Reference to undeclared property \Nosto\Tagging\Model\Service\Sync\AbstractBulkPublisher->authSession (Did you mean $authSession)
$this->logger = $logger;
try {
$this->bulkManagement = ObjectManager::getInstance()
Expand All @@ -107,6 +110,15 @@ public function execute(int $storeId, array $productIds = [])
}
}

private function getCurrentAdminUserId()
{
$user = $this->authSession->getUser();

Check warning on line 115 in Model/Service/Sync/AbstractBulkPublisher.php

View workflow job for this annotation

GitHub Actions / Phan Analysis

Reference to undeclared property \Nosto\Tagging\Model\Service\Sync\AbstractBulkPublisher->authSession
if ($user instanceof \Magento\User\Model\User) {
return $user->getId();
}
return null;
}

/**
* @param $storeId
* @param $productIds
Expand Down Expand Up @@ -150,7 +162,8 @@ private function publishCollectionToMessageQueue(
$result = $this->bulkManagement->scheduleBulk(
$bulkUuid,
$operations,
$bulkDescription
$bulkDescription,
$this->getCurrentAdminUserId()
);
if (!$result) {
/** @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal */
Expand Down

0 comments on commit be315e7

Please sign in to comment.