@@ -1388,24 +1388,30 @@ public function queueNewOrderEmail($forceMode = false)
1388
1388
$ copyMethod = Mage::getStoreConfig (self ::XML_PATH_EMAIL_COPY_METHOD , $ storeId );
1389
1389
1390
1390
// Start store emulation process
1391
- /** @var Mage_Core_Model_App_Emulation $appEmulation */
1392
- $ appEmulation = Mage::getSingleton ('core/app_emulation ' );
1393
- $ initialEnvironmentInfo = $ appEmulation ->startEnvironmentEmulation ($ storeId );
1391
+ if ($ storeId != Mage::app ()->getStore ()->getId ()) {
1392
+ /** @var Mage_Core_Model_App_Emulation $appEmulation */
1393
+ $ appEmulation = Mage::getSingleton ('core/app_emulation ' );
1394
+ $ initialEnvironmentInfo = $ appEmulation ->startEnvironmentEmulation ($ storeId );
1395
+ }
1394
1396
1395
1397
try {
1396
1398
// Retrieve specified view block from appropriate design package (depends on emulated store)
1397
1399
$ paymentBlock = Mage::helper ('payment ' )->getInfoBlock ($ this ->getPayment ())
1398
1400
->setIsSecureMode (true );
1399
1401
$ paymentBlock ->getMethod ()->setStore ($ storeId );
1400
1402
$ paymentBlockHtml = $ paymentBlock ->toHtml ();
1401
- } catch (Exception $ exception ) {
1403
+ } catch (Exception $ e ) {
1402
1404
// Stop store emulation process
1403
- $ appEmulation ->stopEnvironmentEmulation ($ initialEnvironmentInfo );
1404
- throw $ exception ;
1405
+ if (isset ($ appEmulation , $ initialEnvironmentInfo )) {
1406
+ $ appEmulation ->stopEnvironmentEmulation ($ initialEnvironmentInfo );
1407
+ }
1408
+ throw $ e ;
1405
1409
}
1406
1410
1407
1411
// Stop store emulation process
1408
- $ appEmulation ->stopEnvironmentEmulation ($ initialEnvironmentInfo );
1412
+ if (isset ($ appEmulation , $ initialEnvironmentInfo )) {
1413
+ $ appEmulation ->stopEnvironmentEmulation ($ initialEnvironmentInfo );
1414
+ }
1409
1415
1410
1416
// Retrieve corresponding email template id and customer name
1411
1417
if ($ this ->getCustomerIsGuest ()) {
0 commit comments