diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index 0df90deed847a..2fb2c36c5ffec 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -16,6 +16,11 @@ class Creditmemo extends AbstractPdf */ protected $_storeManager; + /** + * @var \Magento\Store\Model\App\Emulation + */ + protected $_appEmulation; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Stdlib\StringUtils $string @@ -29,6 +34,7 @@ class Creditmemo extends AbstractPdf * @param \Magento\Sales\Model\Order\Address\Renderer $addressRenderer * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -47,10 +53,12 @@ public function __construct( \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Store\Model\App\Emulation $appEmulation, array $data = [] ) { $this->_storeManager = $storeManager; $this->_localeResolver = $localeResolver; + $this->_appEmulation = $appEmulation; parent::__construct( $paymentData, $string, @@ -146,6 +154,7 @@ public function getPdf($creditmemos = []) foreach ($creditmemos as $creditmemo) { if ($creditmemo->getStoreId()) { + $this->_appEmulation->startEnvironmentEmulation($creditmemo->getStoreId(), \Magento\Framework\App\Area::AREA_FRONTEND, true); $this->_localeResolver->emulate($creditmemo->getStoreId()); $this->_storeManager->setCurrentStore($creditmemo->getStoreId()); } @@ -183,6 +192,7 @@ public function getPdf($creditmemos = []) } $this->_afterGetPdf(); if ($creditmemo->getStoreId()) { + $this->_appEmulation->stopEnvironmentEmulation(); $this->_localeResolver->revert(); } return $pdf; diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index a55ad35c34fe5..3868c43fe02d5 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -23,6 +23,11 @@ class Invoice extends AbstractPdf */ protected $_localeResolver; + /** + * @var \Magento\Store\Model\App\Emulation + */ + protected $_appEmulation; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Stdlib\StringUtils $string @@ -36,6 +41,7 @@ class Invoice extends AbstractPdf * @param \Magento\Sales\Model\Order\Address\Renderer $addressRenderer * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -53,10 +59,12 @@ public function __construct( \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Store\Model\App\Emulation $appEmulation, array $data = [] ) { $this->_storeManager = $storeManager; $this->_localeResolver = $localeResolver; + $this->_appEmulation = $appEmulation; parent::__construct( $paymentData, $string, @@ -127,6 +135,7 @@ public function getPdf($invoices = []) foreach ($invoices as $invoice) { if ($invoice->getStoreId()) { + $this->_appEmulation->startEnvironmentEmulation($invoice->getStoreId(), \Magento\Framework\App\Area::AREA_FRONTEND, true); $this->_localeResolver->emulate($invoice->getStoreId()); $this->_storeManager->setCurrentStore($invoice->getStoreId()); } @@ -162,6 +171,7 @@ public function getPdf($invoices = []) /* Add totals */ $this->insertTotals($page, $invoice); if ($invoice->getStoreId()) { + $this->_appEmulation->stopEnvironmentEmulation(); $this->_localeResolver->revert(); } } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index f759388699aad..6d6c59e616f8d 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -21,6 +21,11 @@ class Shipment extends AbstractPdf */ protected $_localeResolver; + /** + * @var \Magento\Store\Model\App\Emulation + */ + protected $_appEmulation; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Stdlib\StringUtils $string @@ -34,6 +39,7 @@ class Shipment extends AbstractPdf * @param \Magento\Sales\Model\Order\Address\Renderer $addressRenderer * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -51,10 +57,12 @@ public function __construct( \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Store\Model\App\Emulation $appEmulation, array $data = [] ) { $this->_storeManager = $storeManager; $this->_localeResolver = $localeResolver; + $this->_appEmulation = $appEmulation; parent::__construct( $paymentData, $string, @@ -118,6 +126,7 @@ public function getPdf($shipments = []) $this->_setFontBold($style, 10); foreach ($shipments as $shipment) { if ($shipment->getStoreId()) { + $this->_appEmulation->startEnvironmentEmulation($shipment->getStoreId(), \Magento\Framework\App\Area::AREA_FRONTEND, true); $this->_localeResolver->emulate($shipment->getStoreId()); $this->_storeManager->setCurrentStore($shipment->getStoreId()); } @@ -153,6 +162,7 @@ public function getPdf($shipments = []) } $this->_afterGetPdf(); if ($shipment->getStoreId()) { + $this->_appEmulation->stopEnvironmentEmulation(); $this->_localeResolver->revert(); } return $pdf;