diff --git a/vendor/magento/module-product-alert/Model/Mailing/AlertProcessor.php b/vendor/magento/module-product-alert/Model/Mailing/AlertProcessor.php index 83ac4abd896c..105fb6ac3728 100644 --- a/vendor/magento/module-product-alert/Model/Mailing/AlertProcessor.php +++ b/vendor/magento/module-product-alert/Model/Mailing/AlertProcessor.php @@ -7,6 +7,7 @@ namespace Magento\ProductAlert\Model\Mailing; +use Magento\Framework\App\Area; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Helper\Data; @@ -24,9 +25,15 @@ use Magento\Store\Api\Data\WebsiteInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\Website; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\View\DesignInterface; /** * Class for mailing Product Alerts + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ class AlertProcessor { @@ -78,6 +85,11 @@ class AlertProcessor */ private $errorEmailSender; + /** + * @var DesignInterface + */ + private $design; + /** * @param EmailFactory $emailFactory * @param PriceCollectionFactory $priceCollectionFactory @@ -88,6 +100,7 @@ class AlertProcessor * @param ProductSalability $productSalability * @param StoreManagerInterface $storeManager * @param ErrorEmailSender $errorEmailSender + * @param DesignInterface|null $design */ public function __construct( EmailFactory $emailFactory, @@ -98,7 +111,8 @@ public function __construct( Data $catalogData, ProductSalability $productSalability, StoreManagerInterface $storeManager, - ErrorEmailSender $errorEmailSender + ErrorEmailSender $errorEmailSender, + DesignInterface $design = null ) { $this->emailFactory = $emailFactory; $this->priceCollectionFactory = $priceCollectionFactory; @@ -109,6 +123,8 @@ public function __construct( $this->productSalability = $productSalability; $this->storeManager = $storeManager; $this->errorEmailSender = $errorEmailSender; + $this->design = $design ?: ObjectManager::getInstance() + ->get(DesignInterface::class); } /** @@ -142,6 +158,12 @@ public function process(string $alertType, array $customerIds, int $websiteId): */ private function processAlerts(string $alertType, array $customerIds, int $websiteId): array { + //Set the current design theme + $this->design->setDesignTheme( + $this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND), + Area::AREA_FRONTEND + ); + /** @var Email $email */ $email = $this->emailFactory->create(); $email->setType($alertType);