Magento: Per PHP Setup Script neue Store View anlegen

28. Juni 2011 at 11:01

Per PHP Script eine neue Store View über z.B. Setup-Install-Script anlegen?
So geht’s:

$storeModel = Mage::getModel('core/store');
 $store = array(
 'group_id' => 1,
 'name' => 'New Store Name',
 'code' => 'store_xy',
 'is_active' => 1,
 'sort_order' => 2,
 );
 $storeModel->setData($store);
 $storeModel->setId(null);
 $eventName = 'store_add';
 $groupModel = Mage::getModel('core/store_group')->load($storeModel->getGroupId());
 $storeModel->setWebsiteId($groupModel->getWebsiteId());
 $storeModel->save();
 Mage::app()->reinitStores(); // or Mage::app()->getConfig()->reinit();
 Mage::dispatchEvent($eventName, array('store'=>$storeModel));