77
88namespace Magento \ProductAlert \Model \Mailing ;
99
10+ use Magento \Framework \App \Area ;
1011use Magento \Catalog \Api \Data \ProductInterface ;
1112use Magento \Catalog \Api \ProductRepositoryInterface ;
1213use Magento \Catalog \Helper \Data ;
2425use Magento \Store \Api \Data \WebsiteInterface ;
2526use Magento \Store \Model \StoreManagerInterface ;
2627use Magento \Store \Model \Website ;
28+ use Magento \Framework \App \ObjectManager ;
29+ use Magento \Framework \View \DesignInterface ;
2730
2831/**
2932 * Class for mailing Product Alerts
@@ -78,6 +81,11 @@ class AlertProcessor
7881 */
7982 private $ errorEmailSender ;
8083
84+ /**
85+ * @var DesignInterface
86+ */
87+ private $ design ;
88+
8189 /**
8290 * @param EmailFactory $emailFactory
8391 * @param PriceCollectionFactory $priceCollectionFactory
@@ -88,6 +96,7 @@ class AlertProcessor
8896 * @param ProductSalability $productSalability
8997 * @param StoreManagerInterface $storeManager
9098 * @param ErrorEmailSender $errorEmailSender
99+ * @param DesignInterface|null $design
91100 */
92101 public function __construct (
93102 EmailFactory $ emailFactory ,
@@ -98,7 +107,8 @@ public function __construct(
98107 Data $ catalogData ,
99108 ProductSalability $ productSalability ,
100109 StoreManagerInterface $ storeManager ,
101- ErrorEmailSender $ errorEmailSender
110+ ErrorEmailSender $ errorEmailSender ,
111+ DesignInterface $ design = null
102112 ) {
103113 $ this ->emailFactory = $ emailFactory ;
104114 $ this ->priceCollectionFactory = $ priceCollectionFactory ;
@@ -109,6 +119,8 @@ public function __construct(
109119 $ this ->productSalability = $ productSalability ;
110120 $ this ->storeManager = $ storeManager ;
111121 $ this ->errorEmailSender = $ errorEmailSender ;
122+ $ this ->design = $ design ?: ObjectManager::getInstance ()
123+ ->get (DesignInterface::class);
112124 }
113125
114126 /**
@@ -142,6 +154,12 @@ public function process(string $alertType, array $customerIds, int $websiteId):
142154 */
143155 private function processAlerts (string $ alertType , array $ customerIds , int $ websiteId ): array
144156 {
157+ //Set the current design theme
158+ $ this ->design ->setDesignTheme (
159+ $ this ->design ->getConfigurationDesignTheme (Area::AREA_FRONTEND ),
160+ Area::AREA_FRONTEND
161+ );
162+
145163 /** @var Email $email */
146164 $ email = $ this ->emailFactory ->create ();
147165 $ email ->setType ($ alertType );
0 commit comments