public static function loadAllMenuItem() { $groupId = intval($_POST['groupId']); $module = new VerticalMegaMenus(); $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $response = ''; if ($groupId > 0) { $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "verticalmegamenus_menu_items Where groupId = " . $groupId . " Order By ordering"); if ($items) { foreach ($items as $item) { $itemLang = VerticalMegaMenusLibraries::getMenuItemLangById($item['id'], $langId, $shopId); if ($item['status'] == "1") { $status = '<a title="Enabled" class="list-action-enable action-enabled lik-menu-item-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } else { $status = '<a title="Disabled" class="list-action-enable action-disabled lik-menu-item-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } $banner = $module->getBannerSrc($item['image'], true); if ($banner) { $banner = '<img src="' . $banner . '" width="40" alt="' . $itemLang['imageAlt'] . '" />'; } $response .= '<tr id="mni_' . $item['id'] . '"> <td class="center">' . $item['id'] . '</td> <td>' . $itemLang['title'] . '</td> <td class="center">' . $module->arrType[$item['menuType']] . '</td> <td>' . $item['link'] . '</td> <td class="center">' . $banner . '</td> <td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td> <td class="center">' . $status . '</td> <td class="center"><a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-menu-item-edit"><i class="icon-edit"></i></a> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-menu-item-delete"><i class="icon-trash" ></i></a></td> </tr>'; } } } die(Tools::jsonEncode($response)); }
public function getCategoryLinkOptions($parentId = 0, $selected = '') { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $categoryOptions = ''; if ($parentId <= 0) { $parentId = Configuration::get('PS_HOME_CATEGORY'); } $items = VerticalMegaMenusLibraries::getAllCategories($langId, $shopId, $parentId, '|- ', null); if ($items) { foreach ($items as $item) { $key = 'CAT-' . $item['id_category']; if ($key == $selected) { $categoryOptions .= '<option selected="selected" value="' . $key . '">' . $item['sp'] . $item['name'] . '</option>'; } else { $categoryOptions .= '<option value="' . $key . '">' . $item['sp'] . $item['name'] . '</option>'; } } } return $categoryOptions; }
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']); }