How i get current product name in sendEmail funtion
if (isset($result) && $result) {
$this->emailHelper->sendEmail('Product', $productName);
}
And this is my full code.
<?php
declare(strict_types=1);
namespace custommoduleScheduleContentNotifierPlugin;
use MagentoCatalogStagingModelProductApplier;
use custommoduleScheduleContentNotifierHelperEmail;
use MagentoCatalogModelResourceModelProductCollection;
use MagentoStagingApiUpdateRepositoryInterface;
class PluginProductApplier
{
protected $emailHelper;
protected $product;
/**
* @var UpdateRepositoryInterface
*/
protected $updateRepository;
/**
* @var Collection
*/
protected $productCollectionResource;
/**
* @param UpdateRepositoryInterface $updateRepository
* @param Collection $productResource
* @param ReindexPool $indexerPool
* @param IndexerRegistry $indexerRegistry
*/
public function __construct(
Collection $productResource,
UpdateRepositoryInterface $updateRepository,
Email $emailHelper,
) {
$this->updateRepository = $updateRepository;
$this->productCollectionResource = $productResource;
$this->emailHelper = $emailHelper;
}
/**
* {@inheritdoc}
*/
public function aroundExecute(
ProductApplier $subject,
callable $proceed,
array $entityIds
) {
if ($entityIds) {
$currentVersionId = $this->updateRepository->getVersionMaxIdByTime(
strtotime("now")
);
$select = $this->productCollectionResource->getSelect()->reset(Zend_Db_Select::COLUMNS)->reset(MagentoFrameworkDBSelect::WHERE)->columns(['entity_id', ])
->joinLeft(['ss' => 'staging_update'], 'e.created_in = ss.id', [])
->where('e.entity_id IN (?)', $entityIds)
->where('e.created_in =?', $currentVersionId)
->where('ss.is_rollback IS NULL');
$result = $this->productCollectionResource
->getConnection()
->fetchAll($select);
if (isset($result) && $result) {
$this->emailHelper->sendEmail();
}
}
}
}