Skip to content

Instantly share code, notes, and snippets.

@code-poel
Created March 11, 2014 14:41
Show Gist options
  • Save code-poel/9487167 to your computer and use it in GitHub Desktop.
Save code-poel/9487167 to your computer and use it in GitHub Desktop.
Magento App Emulation
<?php
require_once('app/Mage.php');
Mage::app();
$stores = array_map(function($store) {
return $store->getId();
}, Mage::app()->getStores(true));
foreach ($stores as $store_id) {
// Setup app emulation
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($store_id);
// Load up an emulated category
$cat = Mage::getModel('catalog/category')->load(3);
// Output the URL
echo $cat->getUrl() . PHP_EOL;
// Turn off emulation
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
}
@carlosasin
Copy link

Thanks! you save my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment