/** * @param XmapDisplayerInterface $xmap * @param stdCLass $parent * @param array $params * @param int $catid */ public static function getCategoryTree($xmap, stdClass $parent, array &$params, $catid = 0) { // TODO refactor if (!isset($urlBase)) { $urlBase = JURI::base(); } $vendorId = 1; $children = VmModel::getModel('category')->getChildCategoryList($vendorId, $catid); $xmap->changeLevel(1); foreach ($children as $row) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id; $node->browserNav = $parent->browserNav; $node->name = stripslashes($row->category_name); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->link = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id; if ($xmap->printNode($node) !== false) { self::getCategoryTree($xmap, $parent, $params, $row->virtuemart_category_id); } } $xmap->changeLevel(-1); if ($params['include_products'] && $catid != 0) { $products = self::$productModel->getProductsInCategory($catid); if ($params['include_product_images']) { self::$categoryModel->addImages($products, 1); } $xmap->changeLevel(1); foreach ($products as $row) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id . 'p' . $row->virtuemart_product_id; $node->browserNav = $parent->browserNav; $node->priority = $params['prod_priority']; $node->changefreq = $params['prod_changefreq']; $node->name = $row->product_name; $node->modified = strtotime($row->modified_on); $node->expandible = false; $node->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id; if ($params['include_product_images']) { foreach ($row->images as $image) { if (isset($image->file_url)) { $imagenode = new stdClass(); $imagenode->src = $urlBase . $image->file_url_thumb; $imagenode->title = $row->product_name; $imagenode->license = $params['product_image_license_url']; $node->images[] = $imagenode; } } } $xmap->printNode($node); } $xmap->changeLevel(-1); } }
public function display($tpl = null) { $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers'); require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; //dont remove that file it is actually in every view $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } /* * get the category * This only needs in order to avoid undefined variables */ if (!class_exists('VirtueMartModelCategory')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'category.php'; } $vendorId = 1; $jinput = JFactory::getApplication()->input; $categories = $jinput->get('virtuemart_category_id', array(), 'array'); /*If there is only one category selected and is not zero, display children categories*/ if (count($categories) == 1 && $categories[0] > 0) { $categoryId = $categories[0]; $category_haschildren = true; } else { $categoryId = 0; $category_haschildren = false; } $categoryModel = new VirtueMartModelCategory(); $category = $categoryModel->getCategory($categoryId); $category->haschildren = $category_haschildren; if ($category_haschildren) { $category->children = $categoryModel->getChildCategoryList($vendorId, $categoryId); $categoryModel->addImages($category->children); } /* * show base price variables */ if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings /* * get the products from the cf model */ $products = $this->get('ProductListing'); $model = $this->getModel(); $model->addImages($products); //add stock foreach ($products as $product) { $product->stock = $model->getStockIndicator($product); } //currency if ($products) { if (!class_exists('CurrencyDisplay')) { require_once JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); } //rating if (method_exists('VmModel', 'getModel')) { $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); } //Pagination $u = JFactory::getURI(); $query = $u->getQuery(); //$paginationAction=JRoute::_(JURI::base().'index.php?virtuemart_category_id[0]=3&virtuemart_category_id[1]=1&virtuemart_category_id[2]=5&option=com_customfilters&view=products'); $pagination = $model->getPagination(true); //my model's pagination //get some component parameters $params = JComponentHelper::getParams('com_customfilters'); $perRow = $params->get('prod_per_row', 3); /* * Get the order by list */ $orderByList = $this->get('OrderByList'); $search = null; $this->assignRef('show_prices', $show_prices); $this->assignRef('orderByList', $orderByList); $this->assignRef('products', $products); $this->assignRef('category', $category); $this->assignRef('showBasePrice', $showBasePrice); $this->assignRef('show_prices', $show_prices); $this->assignRef('vmPagination', $pagination); $this->assignRef('paginationAction', $paginationAction); $this->assignRef('perRow', $perRow); $this->assignRef('search', $search); $this->assignRef('showRating', $showRating); $template = VmConfig::get('vmtemplate', 'default'); if (is_dir(JPATH_THEMES . DS . $template)) { $mainframe = JFactory::getApplication(); $mainframe->set('setTemplate', $template); } //$this->setLayoutExt('com_virtuemart'); $this->_prepareDocument(); // parent::display($tpl); }