/** * Returns the HTML for the navigation tree. * * @param MShop_Catalog_Item_Interface $item Catalog item with child nodes * @param array Associative list of catalog IDs as keys and catalog nodes as values * @param array Associative list of parameters used for filtering * @return string Rendered HTML of the navigation tree */ public function transform(MShop_Catalog_Item_Interface $item, array $path, array $params = array()) { if ($item->getStatus() <= 0) { return ''; } $id = $item->getId(); $enc = $this->_encoder; $config = $item->getConfig(); $class = $item->hasChildren() ? ' withchild' : ' nochild'; $class .= isset($path[$item->getId()]) ? ' active' : ''; $class .= isset($config['css-class']) ? ' ' . $config['css-class'] : ''; $params['f_name'] = $item->getName('url'); $params['f_catid'] = $id; $url = $enc->attr($this->_getView()->url($this->_target, $this->_controller, $this->_action, $params, array(), $this->_config)); $output = '<li class="cat-item catid-' . $enc->attr($id . $class) . '" data-id="' . $id . '" >'; $output .= '<a class="cat-item" href="' . $url . '"><div class="media-list">'; foreach ($item->getListItems('media', 'icon') as $listItem) { if (($mediaItem = $listItem->getRefItem()) !== null) { $output .= $this->media($mediaItem, $this->_contentUrl, array('class' => 'media-item')); } } $output .= '</div><span class="cat-name">' . $enc->html($item->getName(), $enc::TRUST) . '</span></a>'; $children = $item->getChildren(); if (!empty($children)) { $output .= '<ul class="level-' . $enc->attr($item->getNode()->level + 1) . '">'; foreach ($children as $child) { $output .= $this->transform($child, $path, $params); } $output .= '</ul>'; } $output .= '</li>'; return $output; }
/** * Adds all texts belonging to an catalog item. * * @param MW_Container_Content_Interface $contentItem Content item * @param MShop_Catalog_Item_Interface $item product item object * @param string $langid Language id */ protected function _addItem(MW_Container_Content_Interface $contentItem, MShop_Catalog_Item_Interface $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); } } }
protected function _delete(MShop_Catalog_Item_Interface $catItem) { $manager = MShop_Catalog_Manager_Factory::createManager($this->_context); $listManager = $manager->getSubManager('list'); foreach ($catItem->getListItems('product') as $listItem) { $listManager->deleteItem($listItem->getId()); } $manager->deleteItem($catItem->getId()); }