4

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?

8

Try this :

$store = Mage::getModel('core/store')->load(Mage_Core_Model_App::DISTRO_STORE_ID);
$rootId = $store->getRootCategoryId();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.