Magento Certified Developer GuideCategory: 7. CatalogCatalog Category: The construction of paths
Manish Prakash Staff asked 5 years ago

path is a column in ‘catalog_category_entity’ table.
This column basically stores the entire path of current category, in terms of its parent categories and current id.

e.g path = 1/2/3/4
this means category ids 1,2,3 are its parent in order and 4 is the id of current category.

The category paths are used in many places and have many advantages
1. Getting the level of category, level basically means depth. Just by looking at the path you can find out category level. No need to have complex sql queries to find level.
2. Getting all children: Its very easy to get all children of a category using path.
So in sql query “where path = ‘1/2/3/%'” will give all children of category id 3
3. You can easily access all parent categories, since you have their ids.

So path is an important component in category structure and plays a vital role.

Path for category is constructed during the afterSave() process

 protected function _afterSave(Varien_Object $object)
         * Add identifier for new category
        if (substr($object->getPath(), -1) == '/') {
            $object->setPath($object->getPath() . $object->getId());

        return parent::_afterSave($object);