Skip to content

Instantly share code, notes, and snippets.

@carlosasin
Forked from code-poel/MageTest.php
Last active August 29, 2015 14:16
Show Gist options
  • Save carlosasin/b752be275b90f0b6f3fc to your computer and use it in GitHub Desktop.
Save carlosasin/b752be275b90f0b6f3fc to your computer and use it in GitHub Desktop.
<?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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment