/** * Returns the list of category label / ID pairs for the given node and all children * * @param MShop_Catalog_Item_Interface $item Catalog item to start from * @param unknown_type $level Current level on indention * @return array Associative array of category label / ID pairs */ protected function getCategoryList(\Aimeos\MShop\Catalog\Item\Iface $item, $level) { $result = array(); $result[] = array(str_repeat('.', $level * 4) . $item->getName(), $item->getId()); foreach ($item->getChildren() as $child) { $result = array_merge($result, $this->getCategoryList($child, $level + 1)); } return $result; }
/** * Returns the list of category label / ID pairs for the given node and all children * * @param MShop_Catalog_Item_Interface $item Catalog item to start from * @param string $breadcrumb Breadcrumb of the parent nodes * @return array Associative array of category label / ID pairs */ protected function getCategoryList(\Aimeos\MShop\Catalog\Item\Iface $item, $breadcrumb) { $result = array(); $result[] = array($breadcrumb, $item->getId()); foreach ($item->getChildren() as $child) { $result = array_merge($result, $this->getCategoryList($child, $breadcrumb . ' > ' . $child->getName())); } return $result; }
/** * Get all child nodes. * * @param \Aimeos\MShop\Catalog\Item\Iface $node * @return \Aimeos\MShop\Catalog\Item\Iface[] $nodes List of nodes */ protected function getNodeList(\Aimeos\MShop\Catalog\Item\Iface $node) { $nodes = array($node); foreach ($node->getChildren() as $child) { $nodes = array_merge($nodes, $this->getNodeList($child)); } return $nodes; }
/** * Creates a list of nodes with children. * * @param \Aimeos\MShop\Catalog\Item\Iface $node Catalog node */ protected function createNodeArray(\Aimeos\MShop\Catalog\Item\Iface $node) { $result = $node->toArray(); foreach ($node->getChildren() as $child) { $result['children'][] = $this->createNodeArray($child); } return (object) $result; }
/** * Returns the list of catalog IDs for the given catalog tree * * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children * @return array List of catalog IDs */ protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) { $list = array($item->getId()); foreach ($item->getChildren() as $child) { $list = array_merge($list, $this->getCatalogIdsFromTree($child)); } return $list; }
/** * Returns the category IDs of the given catalog tree. * * Only the IDs of the children of the current category are returned. * * @param \Aimeos\MShop\Catalog\Item\Iface $tree Catalog node as entry point of the tree * @param array $path Associative list of category IDs as keys and the catalog * nodes from the currently selected category up to the root node * @param string $currentId Currently selected category * @return array List of category IDs */ protected function getCatalogIds(\Aimeos\MShop\Catalog\Item\Iface $tree, array $path, $currentId) { if ($tree->getId() == $currentId) { $ids = array(); foreach ($tree->getChildren() as $item) { $ids[] = $item->getId(); } return $ids; } foreach ($tree->getChildren() as $child) { if (isset($path[$child->getId()])) { return $this->getCatalogIds($child, $path, $currentId); } } return array(); }