3

can I use install scripts to configure multiple stores and views?

Can I find any examples? thanks

15

To add a store use the code below:

//#addWebsite
/** @var $website Mage_Core_Model_Website */
$website = Mage::getModel('core/website');
$website->setCode('<your_website_code_here>')
    ->setName('<your_website_name>')
    ->save();

//#addStoreGroup
/** @var $storeGroup Mage_Core_Model_Store_Group */
$storeGroup = Mage::getModel('core/store_group');
$storeGroup->setWebsiteId($website->getId())
    ->setName('<your_store_name>')
    ->setRootCategoryId('<needed_root_category_id>')
    ->save();

//#addStore
/** @var $store Mage_Core_Model_Store */
$store = Mage::getModel('core/store');
$store->setCode('<your_store_view_code_here>')
    ->setWebsiteId($storeGroup->getWebsiteId())
    ->setGroupId($storeGroup->getId())
    ->setName('<your_store_view_name>')
    ->setIsActive(1)
    ->save();

Thanks to Zyava for providing this answer

  • 1
    Sorry, is that an install or data script? thanks – Antonio Pedicini Jan 27 '15 at 14:22

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.