Question

I have a data install script which requires access to the default stores root category.

If the code for the module is run when the site is first installed, the value is never available i.e.

Mage::app()->getStore()->getRootCategoryId()

returns null

because

Mage::app()->getStore()

returns 0 instead of 1.

I suspect this is something related to the stores not being fully during installation. How can i get access to the default store views root category id during installation?

Was it helpful?

Solution

Try this :

$store = Mage::getModel('core/store')->load(Mage_Core_Model_App::DISTRO_STORE_ID);
$rootId = $store->getRootCategoryId();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top