Last active
August 12, 2016 13:02
-
-
Save 0-Sony/fa5850a7fbb19e5193c1 to your computer and use it in GitHub Desktop.
Change Name Category programmaticaly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Location : Namespace/module/data/namespace_module_setup/install-0.1.0.php | |
try { | |
$storeId = 4 // your target store; | |
/** | |
* Set the right Store | |
*/ | |
Mage::app()->setCurrentStore($storeId); | |
$_helperCategory = Mage::helper('catalog/category'); | |
/** | |
* Retrieves the categorie of the current store | |
*/ | |
$cats = $_helperCategory->getStoreCategories(); | |
/** | |
* Switch to the Admin Store to save | |
*/ | |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
$categoryModel = Mage::getModel('catalog/category'); | |
foreach ($cats as $cat) { | |
/** retrieves your category by what you want */ | |
if ($cat->getName() == 'Old Custom Name') { | |
$categoryModel->setStoreId(0); | |
$categoryModel->load($cat->getId()); | |
$categoryModel->setName('My New Custom Name')->save(); | |
} | |
} | |
} catch (Exception $e) { | |
// Silence is golden | |
Mage::logException($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment