Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
 /**
  * Adds all texts belonging to an catalog item.
  *
  * @param \Aimeos\MW\Container\Content\Iface $contentItem Content item
  * @param \Aimeos\MShop\Catalog\Item\Iface $item product item object
  * @param string $langid Language id
  */
 protected function addItem(\Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Catalog\Item\Iface $item, $langid)
 {
     $listTypes = array();
     foreach ($item->getListItems('text') as $listItem) {
         $listTypes[$listItem->getRefId()] = $listItem->getType();
     }
     foreach ($this->getTextTypes('catalog') as $textTypeItem) {
         $textItems = $item->getRefItems('text', $textTypeItem->getCode());
         if (!empty($textItems)) {
             foreach ($textItems as $textItem) {
                 $listType = isset($listTypes[$textItem->getId()]) ? $listTypes[$textItem->getId()] : '';
                 $items = array($langid, $item->getLabel(), $item->getId(), $listType, $textTypeItem->getCode(), '', '');
                 // use language of the text item because it may be null
                 if (($textItem->getLanguageId() == $langid || is_null($textItem->getLanguageId())) && $textItem->getTypeId() == $textTypeItem->getId()) {
                     $items[0] = $textItem->getLanguageId();
                     $items[5] = $textItem->getId();
                     $items[6] = $textItem->getContent();
                 }
                 $contentItem->add($items);
             }
         } else {
             $items = array($langid, $item->getLabel(), $item->getId(), 'default', $textTypeItem->getCode(), '', '');
             $contentItem->add($items);
         }
     }
 }
Exemple #4
0
 /**
  * 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;
 }
Exemple #5
0
 protected function delete(\Aimeos\MShop\Catalog\Item\Iface $catItem)
 {
     $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context);
     $listManager = $manager->getSubManager('lists');
     foreach ($catItem->getListItems('product') as $listItem) {
         $listManager->deleteItem($listItem->getId());
     }
     $manager->deleteItem($catItem->getId());
 }
Exemple #6
0
 /**
  * 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();
 }