Open navigation

How to show category hierarchy in search suggestions?

Please follow the steps below to show the category hierarchy in search suggestions. Please note, this will show maximum three level of category hierarchy in category suggestion.

This solution is only for Magento 1 platform.

1. Open app/code/community/Klevu/Search/Model/Product/Sync.php

2. Search for the line below:

$value["name"] = $category->getName();

3. Replace above with the below one:

if($category->getParentCategory()->getLevel() > 1) {
if($category->getParentCategory()->getLevel() > 1){
$value["name"] = $category->getParentCategory()->getParentCategory()->getName()." > ".$category->getParentCategory()->getName()." > ".$category->getName();
} else {
$value["name"] = $category->getParentCategory()->getName()." > ".$category->getName();
} else {
$value["name"] = $category->getName();

4. Perform full product sync by following the guide below, please remember to select the "All Data" option.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.