Magento get category id by category name and category parent name -


i'm able category id using category name in snippet below

 $category = mage::getresourcemodel('catalog/category_collection')->addfieldtofilter('name', 'clothing');     $cat= $category->getdata();  $categoryid = $cat[0][entity_id]; 

the problem, however, if 2 parent categories have subcategories same name, how can category id using parent name

for instance category men has subcategory clothing , category women has subcategory clothing. using abve code return id clothing in women or clothing in men. want find way ensure subcategory id clothing men or vice versa.

any pointers appreciated

in case want parent first, appropriate child:

$category = mage::getresourcemodel('catalog/category_collection')     ->addfieldtofilter('name', 'men')     ->getfirstitem() // parent category         ->getchildrencategories()         ->addfieldtofilter('name', 'clothing')         ->getfirstitem(); // child category  $categoryid = $category->getid(); 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -