Skip to content

Instantly share code, notes, and snippets.

@razbakov
Created May 17, 2013 14:33
Show Gist options
  • Save razbakov/5599430 to your computer and use it in GitHub Desktop.
Save razbakov/5599430 to your computer and use it in GitHub Desktop.
<?php
$installer = $this;
$installer->startSetup();
Mage::register('isSecureArea', 1);
Mage::app()->setUpdateMode(false);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$db = Mage::getSingleton('core/resource')->getConnection('core_read');
$rootIds = $db->query('SELECT g.root_category_id, s.store_id
FROM ' . $installer->getTable('core_store_group') . ' g
LEFT JOIN ' . $installer->getTable('core_website') . ' w ON w.default_group_id = g.group_id
LEFT JOIN ' . $installer->getTable('core_store') . ' s ON s.group_id = g.group_id
WHERE (w.code = "zurrose_ch" OR w.code = "zr_ch_helsana")
AND (s.code LIKE "%_fr")')->fetchAll();
foreach ($rootIds as $group) {
$category = Mage::getModel('catalog/category')->load($group['root_category_id']);
$newId = Mage::getModel('catalog/category')
->setStoreId(0)
->setPath($category->getPath())
->setParentId($category->getId())
->setName('Jetzt aktuell')
->setUrlKey('separator')
->setIsActive(true)
->setIncludeInMenu(true)
->save()
->getId();
Mage::getModel('catalog/category')->load($newId)
->setStoreId($group['store_id'])
->setName('Actuel')
->save();
}
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment