static function getCategoryIds($parentId = 0, $arr = null) { if ($arr == null) { $arr = array(); } $items = DB::getInstance()->executeS("Select id_category From " . _DB_PREFIX_ . "category Where id_parent = {$parentId}"); if ($items) { foreach ($items as $item) { $arr[] = $item['id_category']; $arr = VerticalMegaMenusLibraries::getCategoryIds($item['id_category'], $arr); } } return $arr; }
function buildGroup_Products_default($group, $langId, $shopId) { //if (!$this->isCached('group.product.tpl', 'product|'.$group['id'])){ $params = json_decode($group['params']); //array('saller'=>$this->l('Best Saller'), 'view'=>$this->l('Most View'), 'special'=>$this->l('Specials'), 'arrival'=>$this->l('New Arrivals'), 'manual'=>$this->l('Manual')); if ($params->productType == 'saller') { $arrSubCategory = VerticalMegaMenusLibraries::getCategoryIds($params->productCategory); $arrSubCategory[] = $params->productCategory; $products = $this->getProductsOrderSales($langId, $arrSubCategory, null, false, false, $params->productCount, 0, true); } elseif ($params->productType == 'special') { $arrSubCategory = VerticalMegaMenusLibraries::getCategoryIds($params->productCategory); $arrSubCategory[] = $params->productCategory; $products = $this->getProductsOrderSpecial($langId, $arrSubCategory, null, false, false, $params->productCount, 0, true); } elseif ($params->productType == 'arrival') { $arrSubCategory = VerticalMegaMenusLibraries::getCategoryIds($params->productCategory); $arrSubCategory[] = $params->productCategory; $products = $this->getProductsOrderAddDate($langId, $arrSubCategory, null, false, false, $params->productCount, 0, true); } elseif ($params->productType == 'manual') { $products = $this->getProductsByIds($langId, $params->productIds, false, true); } $timeNow = time(); $currency = new Currency($this->context->currency->id); $link = Context::getContext()->link; $http = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $http .= "s"; } $http .= "://"; if ($products) { foreach ($products as $i => &$product) { if (isset(self::$productCache['prod-' . $product['id_product']]) && self::$productCache['prod-' . $product['id_product']]) { $product = self::$productCache['prod-' . $product['id_product']]; } else { $properties = Product::getProductProperties($langId, $product); $id_image = Product::getCover($product['id_product']); $imagePath = $link->getImageLink($product['link_rewrite'], $id_image['id_image'], 'home_default'); if (strpos($imagePath, $http) === false) { $imagePath = $http . $imagePath; } $product['image'] = $imagePath; $product['price_new'] = number_format(Tools::convertPriceFull($properties['price'], $currency), 2, '.', ','); $product['price_old'] = '0'; $product['reduction'] = ''; $product['link'] = $properties['link']; $specific_prices = $properties['specific_prices']; $oldPrice = ''; $sale = ''; if ($specific_prices) { $from = strtotime($specific_prices['from']); $to = strtotime($specific_prices['to']); $product['price_old'] = number_format(Tools::convertPriceFull($properties['price_without_reduction'], $currency), 2, '.', ','); if ($specific_prices['from_quantity'] == '1' && ($timeNow >= $from && $timeNow <= $to || $specific_prices['to'] == '0000-00-00 00:00:00')) { if ($specific_prices['reduction_type'] == 'percentage') { $product['reduction'] = $specific_prices['reduction'] * 100 . '%'; } else { $product['reduction'] = $currency->sign . number_format(Tools::convertPriceFull($specific_prices['reduction'], $currency), 2, '.', ','); } } } self::$productCache['prod-' . $product['id_product']] = $product; } } } $this->context->smarty->assign(array('currencySign' => $currency->sign, 'verticalProducts' => $products, 'params' => get_object_vars($params))); //} return $this->display(__FILE__, 'group.product.tpl', 'product|' . $group['id']); }