×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Roman Ignatov
Added: Nov 22, 2016 4:33 PM
Views: 8
Tags: magento
  1. <?php
  2.  
  3. // Start store emulation process
  4. /**
  5. * @var Mage_Core_Model_App_Emulation $appEmulation
  6. */
  7. $appEmulation = Mage::getSingleton('core/app_emulation');
  8. $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeIdToEmulate);
  9.  
  10. try {
  11.  
  12.         // .... logic which have to be in store env proceed
  13.  
  14. } catch (Exception $e) {
  15.     Mage::logException($e);
  16.     // do not forget stop emulation if some error happens
  17.     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
  18.     throw $e;
  19. }
  20.  
  21. // at the and of our logic - stop emulation
  22. $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);