storeManager = $storeManager; $this->emulation = $emulation; $this->areaList = $areaList; $this->appState = $appState; } /** * Emulate the correct store during email preparation * * @param TransportBuilder $subject * @param \Closure $proceed * @return mixed * @throws NoSuchEntityException|LocalizedException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundGetTransport(TransportBuilder $subject, \Closure $proceed) { // Load translations for the app $area = $this->areaList->getArea($this->appState->getAreaCode()); $area->load(AreaInterface::PART_TRANSLATE); $currentStore = $this->storeManager->getStore(); $this->emulation->startEnvironmentEmulation($currentStore->getId()); $output = $proceed(); $this->emulation->stopEnvironmentEmulation(); return $output; } }