0
votes

i want to get the catageory path of a category.

I got the parent and the child name and i'm doing the following:

$categorys = Mage::getResourceModel('catalog/category_collection')
    ->addAttributeToFilter('name', array("like" => $sCatName))
    ->getFirstItem()
    ->getChildrenCategories()
    ->addAttributeToFilter('name', array("like" => $sCatNameChild))
    ->addAttributeToSelect('*');

I checked the result with echo $categorys->getSelectSql();

It returns the correct Sql, run it over sql return 1 cat (correct one)

I count the collection and there are 8 selected categorys in there ( all subs of the parent)

Any idea why this is happening ?

1
Can you tell us what you think should be returned? it looks like you are trying to find the first parent category, and then find all the children with a specific name? - Douglas Radburn
Yeah that's exactly what i am looking for. All parents habe a different name so there is always just 1 parent with differnet childs - Mr. Metz

1 Answers

0
votes

Assuming $id is the id of your category. You may get path like this $category = Mage::getModel('catalog/category')->load($id); $path = explode('/', $category->getPath());

I have not tested this code but it must work