I was able to achieve my desired functionality by modifying the filterCat() function as shown below.
public function filterCat($data, $field = null) {
if (empty($data['cid'])) {
return array();
}
$cat[] = $data['cid'];
// Get child categories
$children = $this->Category->children($cat['0'],false,'id');
// extract the ids of the child categories
$children = Hash::extract($children, '{n}.Category.id');
// if no child categories, return requested category id
if(empty($children)){
return array(
$this->alias . '.category_id' => $cat);
}else{
// else merge array of child category ids with parent category id
// and create SQL string to match the list of category ids
$children = array_merge($cat,$children);
return array(
$this->alias . '.category_id IN ' => $children);
}
}
The function looks for child categories, if there are no child categories it returns the search string with the category id. If there are child categories, it returns the search string with the parent and child category ids in a list.
I know this is an old question, but hopefully this can help others.
CakePHP version 2.2.3 and CakeDC search plugin version 2.1