"Create Store View" programmatically in magento 1.6

To create store view use model "Mage_Core_Model_Store". You will need to specify Website Id, Store Group Id, Store View Name, Store View Code and Status.

Website Id - Store will be associated under this website.

Store Group Id - Store view will be associated under this store.

Store View Name - Name of your store view. eg. english

Store View Code - Code for this store view.

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

  $websiteId = 2; // "Create website" programatically $website->getId(); or $storeGroup->getWebsiteId();
  $storeGroupId = 3; // "Create Store Group" programatically $storeGroup->getId();
  $storeViewName = "english";
  $storeViewCode = "english";

  // Create store object
  $store = Mage::getModel('core/store');
  try {
    $store->setCode($storeViewCode)
          ->setWebsiteId($websiteId)
          ->setGroupId($storeGroupId)
          ->setName($storeViewName)
          ->setIsActive(1)
          ->save();
  }
  catch (Exception $e){
    echo $e->getMessage();
  }

 

Tutorial may help you:

Create website programatically

Create Store Group programatically in magento

Create Root Category programatically in magento

Created At: 25 April, 2024

Views: 5,405



Social Sharing
Search