/** * Returns whether $node is a parent (not exactly direct) of a selected node * * @param Varien_Data_Tree_Node $node * @return bool */ protected function _isParentSelectedCategory($node) { $result = false; // Contains string with all category IDs of children (not exactly direct) of the node $allChildren = $node->getAllChildren(); if ($allChildren) { $selectedCategoryIds = $this->getCategoryIds(); $allChildrenArr = explode(',', $allChildren); for ($i = 0, $cnt = count($selectedCategoryIds); $i < $cnt; $i++) { $isSelf = $node->getId() == $selectedCategoryIds[$i]; if (!$isSelf && in_array($selectedCategoryIds[$i], $allChildrenArr)) { $result = true; break; } } } return $result; }