Last active
August 4, 2016 00:30
-
-
Save tuanphpvn/afe1c63ec50cf7d763da to your computer and use it in GitHub Desktop.
Get all category id by Level 2 (Level -1 is root category)
This file contains hidden or 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 | |
$getAllIdOfRootCategory = function($catname) { | |
$rootCategoryObj = Mage::getModel('catalog/category')->loadByAttribute('name', $catname); | |
$collection = Mage::getModel('catalog/category') | |
->getCollection() | |
->addPathsFilter($rootCategoryObj->getPath().'/'); | |
$arr = array(); | |
foreach($collection as $catObj) { | |
$arr[] = $catObj->getId(); | |
} | |
return implode(",", $arr); | |
}; | |
//echo $getAllIdOfRootCategory('AcerEMEA Root'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment