"Create Store Group" programmatically in magento 1.6

To create store group use model "Mage_Core_Model_Store_Group". You will need to specify Website Id, Store Name and Root Category Id.

Website Id - Store will be associated under this website.

Store Name - Name of your store. eg. mystore

Root Category Id - Root Category will be used for this store.

You can use following script to create store group in magento v1.6.

$websiteId = "2"; // "Create Website" programatically $website->getId();
$rootCategoryId = "4"; // "Create Root Category" programatically $category->getId();
$storeName = "mystore";

// Create Store Group Object
$storeGroup = Mage::getModel('core/store_group');
try {
  $storeGroup->setWebsiteId($websiteId)
             ->setName($storeName)
             ->setRootCategoryId($rootCategoryId)
             ->save();
}
catch (Exception $e){
  echo $e->getMessage();
}

 

Tutorial may help you:

Create Website programatically in magento

Create Root Category programatically in magento

Created At: 22 December, 2024

Views: 4,353



Social Sharing
Search