public function renderContent($setting) { $t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $context = Context::getContext(); //$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false; $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array(); //echo "<pre>".print_r($categorytab,1); die; $categories = $this->getCategories($setting['categoryBox'], $context->language->id); if ($categories) { foreach ($categories as &$category) { $obj = new Category($category['id_category']); $category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true); $category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false); $category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false; $category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id); $tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : ''; if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) { $category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon']; } else { $category['icon'] = ''; } $category['icon_class'] = $tg['icon_class']; } } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['categories_info'] = $categories; $output = array('type' => 'categoriesinfo', 'data' => $setting); return $output; }
public function renderContent($setting) { $t = array('list_type' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200'); $products = array(); $setting = array_merge($t, $setting); switch ($setting['list_type']) { case 'newest': $products = Product::getNewProducts($this->lang_id, 0, (int) $setting['limit']); break; case 'featured': $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id); $nb = (int) $setting['limit']; $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); break; case 'bestseller': $products = ProductSale::getBestSalesLight((int) $this->lang_id, 0, (int) $setting['limit']); break; case 'special': $products = Product::getPricesDrop($this->lang_id, 0, (int) $setting['limit']); break; } $setting['products'] = $products; $output = array('type' => 'productlist', 'data' => $setting); return $output; }
/** * */ public function renderContent($setting) { $t = array('categorytab' => '', 'categoryBox' => '', 'limit' => 6, 'itemsperpage' => 4, 'columns' => 4, 'order_by' => 'date_add DESC', 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $porder = preg_split('#\\s+#', $setting['order_by']); if (!isset($porder[1])) { $porder[1] = null; } $output = array(); $context = Context::getContext(); $categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false; $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array(); if ($categories) { $tg = array(); foreach ($categories as $id_category) { $obj = new Category($id_category, $context->language->id); $tg['category_info'] = isset($categorytab[$id_category]) ? $categorytab[$id_category] : ''; if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['category_info']['icon'])) { $tg['category_info']['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['category_info']['icon']; } else { $tg['category_info']['icon'] = ''; } $tg['category_obj'] = $obj; $tg['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], $porder[0], $porder[1]); $output[] = $tg; } } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['categories_tabs'] = $output; $output = array('type' => 'categoriestabs', 'data' => $setting); return $output; }
public function renderContent($args, $setting) { $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6; $catids = $setting['categories'] ? $setting['categories'] : array(); $orderby = $setting['orderby'] ? $setting['orderby'] : 'position'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC'; $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3; $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3; $categories = array(); foreach ($catids as $catid) { $category = new Category($catid, (int) Context::getContext()->language->id); if ($category->id) { $categories[$catid]['id'] = $category->id; $categories[$catid]['name'] = $category->name; $categories[$catid]['link'] = $category->getLink(); $products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($products); $categories[$catid]['products'] = $products; } } $setting['leocategories'] = $categories; $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['scolumn'] = 12 / $columns_page; $setting['myTab'] = 'leocategorytab' . rand(20, rand()); $output = array('type' => 'categoriestabs', 'data' => $setting); return $output; }
public function hookblockPosition3($params) { $arrayCategory = array(); $catSelected = Configuration::get($this->name . '_list_cate'); $cateArray = explode(',', $catSelected); $id_lang = (int) Context::getContext()->language->id; $id_shop = (int) Context::getContext()->shop->id; $arrayProductCate = array(); foreach ($cateArray as $id_category) { $id_category = str_replace('CAT', '', $id_category); $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop); $categoryProducts = $category->getProducts($this->context->language->id, 0, 20); $child_cate = Category::getChildren($id_category, $id_lang); $categoryids = $this->getimage($id_category, $id_shop); foreach ($categoryids as $categoryid) { } $html = ''; $files = scandir(_PS_CAT_IMG_DIR_); if (count($files) > 0) { foreach ($files as $value => $file) { if (preg_match('/' . $id_category . '-([0-9])?_thumb.jpg/i', substr($file, 0)) === 1) { if (preg_match('/' . $id_category . '-([0-9])?_thumb.jpg/i', substr($file, 1)) != 1) { $html .= '<img alt="img" class="img-responsive cate_thumb_icon" src="' . $this->context->link->getMediaLink(_THEME_CAT_DIR_ . $file) . '"/>'; } } } } if ($categoryProducts) { $arrayProductCate[] = array('id' => $id_category, 'html' => $html, 'name' => $category->name, 'product' => $categoryProducts, 'child_cate' => $child_cate, 'cate_id' => $categoryid); } } $this->smarty->assign(array('productCates' => $arrayProductCate)); return $this->display(__FILE__, 'poscategorythumb.tpl'); }
function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, $nb ? $nb : 10); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); }
function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, $nb ? $nb : 10); $smarty->assign(array('allow_buy_when_out_of_stock' => Configuration::get('PS_ORDER_OUT_OF_STOCK', false), 'max_quantity_to_allow_display' => Configuration::get('PS_LAST_QTIES'), 'category' => $category, 'products' => $products, 'currency' => new Currency(intval($params['cart']->id_currency)), 'lang' => Language::getIsoById(intval($params['cookie']->id_lang)), 'productNumber' => sizeof($products), 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); }
function hookHomeCategory($params) { global $smarty; if (isset($_GET['id_category'])) { $categoryid = $_GET['id_category']; } $category = new Category($categoryid, Configuration::get('PS_LANG_DEFAULT')); $products1 = $category->getProducts((int) $params['cookie']->id_lang, 1, 3, 'date_add', 'DESC'); $smarty->assign(array('products1' => $products1, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'blocknewproduct.tpl'); }
public function renderContent($setting) { $t = array('id_parent' => '', 'limit' => '12', 'image_width' => '200', 'image_height' => '200'); $setting = array_merge($t, $setting); $nb = (int) $setting['limit']; $category = new Category($setting['id_parent'], $this->lang_id); $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); $setting['products'] = $products; $output = array('type' => 'productcategory', 'data' => $setting); return $output; }
public function renderContent($args, $setting) { $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6; $orderby = $setting['orderby'] ? $setting['orderby'] : 'position'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC'; $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3; $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3; $interval = $setting['interval'] ? (int) $setting['interval'] : 8000; $iso_code = Context::getContext()->language->iso_code; $setting['tabs'] = array(); $result['products'] = array(); if ($setting['leotab']) { $tabs = $setting['leotab']; $items = $this->getTabs($tabs); foreach ($items as $item) { if ($item['categories'] || $item['type']) { $categories = $item['categories'] ? implode($item['categories'], ",") : ''; $where = ''; if ($categories) { $where = 'cp.`id_category` IN (' . $categories . ') AND '; } if ($item['type'] == 'new') { $result['products'] = $this->getNewProducts($where, (int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); } elseif ($item['type'] == 'special') { $result['products'] = $this->getPricesDrop($where, (int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); } elseif ($item['type'] == 'bestseller') { $result['products'] = $this->getBestSales($where, (int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway); } elseif ($item['type'] == 'featured') { $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $result['products'] = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); } else { if ($categories) { $where = 'WHERE cp.`id_category` IN (' . $categories . ')'; } $result['products'] = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); } $result['title'] = $item['title_' . $iso_code] ? $item['title_' . $iso_code] : ''; $result['icon'] = $item['icon'] ? $item['icon'] : ''; $result['id_tab'] = $item['id_tab'] ? $item['id_tab'] : 0; $setting['tabs'][] = $result; } } } $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['interval'] = $interval; $setting['path'] = __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/img/icontab/'; $setting['scolumn'] = 12 / $columns_page; $setting['myTab'] = 'advancetab' . rand(20, rand()); $output = array('type' => 'advancetab', 'data' => $setting); return $output; }
public function renderContent($setting) { $t = array('category_id' => '', 'limit' => '12', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $nb = (int) $setting['limit']; $category = new Category($setting['category_id'], $this->lang_id); $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['products'] = $products; $output = array('type' => 'products', 'data' => $setting); return $output; }
public function renderContent($setting) { $t = array('category_id' => '', 'limit' => '12', 'image_width' => '200', 'image_height' => '200', 'image' => '', 'banner_imagefile' => '', 'imageurl' => '', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $nb = (int) $setting['limit']; if ($setting['banner_imagefile']) { $setting['bannerurl'] = _PAGEBUILDER_IMAGE_URL_ . $setting['banner_imagefile']; } $category = new Category($setting['category_id'], $this->lang_id); $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['products'] = $products; $output = array('type' => 'products', 'data' => $setting); return $output; }
public function renderContent($args, $setting) { # validate module unset($args); $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 8; $orderby = $setting['orderby'] ? $setting['orderby'] : 'date_add'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'date_add'; $items_page = $columns_page = 3; if (isset($setting['itemspage']) && $setting['itemspage']) { $items_page = $setting['itemspage']; } if (isset($setting['columns']) && $setting['columns']) { $columns_page = $setting['columns']; } $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000; switch ($setting['specialtype']) { case 'newest': $products = Product::getNewProducts($this->langID, 0, $nb, false, $orderby, $orderway); break; case 'featured': $category = new Category(Context::getContext()->shop->getCategory(), $this->langID); $products = $category->getProducts((int) $this->langID, 1, $nb, $orderby, $orderway); break; case 'bestseller': $products = ProductSale::getBestSalesLight((int) $this->langID, 0, $nb); break; case 'special': $products = Product::getPricesDrop($this->langID, 0, $nb, false, $orderby, $orderway); break; case 'random': $random = true; $products = $this->getProducts('WHERE p.id_product > 0', (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway, false, true, $random, $nb); Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1'); break; } $setting['specialtype'] = $setting['specialtype']; Context::getContext()->controller->addColorsToProductList($products); $setting['products'] = $products; $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['scolumn'] = 12 / $columns_page; $setting['interval'] = $interval; $setting['tab'] = 'leospecialproduct' . rand(20, rand()); $output = array('type' => 'specialproduct', 'data' => $setting); return $output; }
public function renderContent($args, $setting) { # validate module unset($args); $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $setting['special'] = array(); $setting['bestseller'] = array(); $setting['featured'] = array(); $setting['newproducts'] = array(); $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6; $orderby = $setting['orderby'] ? $setting['orderby'] : 'position'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC'; $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3; $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3; $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000; if ($setting['featured_display'] && $setting['featured_display'] == 1) { $pro_featured = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_featured); $setting['featured'] = $pro_featured; } if ($setting['newarrivals_display'] && $setting['newarrivals_display'] == 1) { $pro_newproducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_newproducts); $setting['newproducts'] = $pro_newproducts; } if ($setting['special_display'] && $setting['special_display'] == 1) { $pro_special = Product::getPricesDrop((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_special); $setting['special'] = $pro_special; } if ($setting['bestseller_display'] && $setting['bestseller_display'] == 1) { $pro_bestseller = ProductSale::getBestSales((int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_bestseller); $setting['bestseller'] = $pro_bestseller; } $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['interval'] = $interval; $setting['scolumn'] = 12 / $columns_page; $setting['homeSize'] = Image::getSize(ImageType::getFormatedName('home')); $setting['myTab'] = 'leoproducttab' . rand(20, rand()); $output = array('type' => 'producttabs', 'data' => $setting); return $output; }
/** * Récupération de la liste des produits * @param string $type * @param int $nb_products */ protected function _getProducts($type, $nb_products) { switch ($type) { case 'price_drop': return Product::getPricesDrop((int) $this->context->language->id, 0, $nb_products); break; case 'category': $this->_datas['id_category'] ? $id_category = $this->_datas['id_category'] : ($id_category = (int) Configuration::get('HOME_FEATURED_CAT')); $category = new Category($id_category, (int) $this->context->language->id); return $category->getProducts((int) $this->context->language->id, 1, $nb_products, 'position'); break; case 'new': default: return Product::getNewProducts((int) $this->context->language->id, 0, $nb_products); break; } }
function hookHome($params) { $number_categorydisplay = 3; global $smarty; $categories = Category::getHomeCategories((int) $params['cookie']->id_lang, true); shuffle($categories); for ($i = 0; $i < $number_categorydisplay; $i++) { $categorydisplay[] = $categories[$i]; } //var_dump($categorydisplay); foreach ($categorydisplay as $cate) { $category = new Category($cate[id_category], Configuration::get('PS_LANG_DEFAULT')); $nb = (int) Configuration::get('HOME_FEATURED_NBR'); $products[$cate[id_category]] = $category->getProducts((int) $params['cookie']->id_lang, 1, 10, null, null, false, true, true, 3); $n++; } $smarty->assign(array('products' => $products, 'categories' => $categorydisplay, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'blocknewproductcatagories.tpl'); }
/** * */ public function renderContent($setting) { $t = array('sub_title' => '', 'categoryBox' => '', 'list_type' => '', 'limit' => 8, 'image_width' => '200', 'image_height' => '200', 'enable_special' => '1', 'enable_bestseller' => '1', 'enable_featured' => '0', 'enable_newest' => '1', 'enable_toprating' => 0, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $output = array(); // if ($setting['enable_newest']) { $output['newest']['key'] = 'newest' . time(); $output['newest']['title'] = $this->l('New arrivals', 'producttabs'); $output['newest']['products'] = self::getNewProducts($setting['categoryBox'], $this->lang_id, 0, (int) $setting['limit']); } if ($setting['enable_bestseller']) { $output['bestseller']['key'] = 'bestseller' . time(); $output['bestseller']['title'] = $this->l('Bestseller', 'producttabs'); $output['bestseller']['products'] = self::getBestSalesLight($setting['categoryBox'], (int) $this->lang_id, 0, (int) $setting['limit']); } if ($setting['enable_featured']) { $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id); $nb = (int) $setting['limit']; $output['featured']['key'] = 'featured' . time(); $output['featured']['title'] = $this->l('Featured', 'producttabs'); $output['featured']['products'] = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); } if ($setting['enable_special']) { $output['special']['key'] = 'special' . time(); $output['special']['title'] = $this->l('Special', 'producttabs'); $output['special']['products'] = self::getPricesDrop($setting['categoryBox'], $this->lang_id, 0, (int) $setting['limit']); } if ($setting['enable_toprating']) { $output['toprating']['key'] = 'toprating' . time(); $output['toprating']['title'] = $this->l('Top Rating', 'producttabs'); $output['toprating']['products'] = self::getProducts($setting['categoryBox'], 0, (int) $setting['limit']); } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['producttabs'] = $output; $language_id = Context::getContext()->language->id; $setting['sub_title'] = isset($setting['sub_title_' . $language_id]) ? $setting['sub_title_' . $language_id] : ''; $output = array('type' => 'producttabs', 'data' => $setting); return $output; }
public function hookHome($params) { if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'index') { return; } $catSelected = Configuration::get($this->name . 'category'); $cateArray = explode(',', $catSelected); $id_lang = (int) Context::getContext()->language->id; $id_shop = (int) Context::getContext()->shop->id; $arrayCategory = array(); foreach ($cateArray as $id_category) { $id_category = str_replace('CAT', '', $id_category); $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop); $categoryProducts = $category->getProducts($this->context->language->id, 0, 20); $html = ''; if ($categoryProducts) { $arrayCategory[] = array('id' => $id_category, 'html' => $html, 'name' => $category->name, 'product' => $categoryProducts); } } $this->smarty->assign(array('tmcategoryinfos' => $arrayCategory)); return $this->display(__FILE__, 'tmcategoryslider.tpl'); }
public function renderContent($setting) { $t = array('sub_title' => '', 'categoryBox' => '', 'list_type' => '', 'list_mode' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200', 'description' => '', 'image' => '', 'banner_imagefile' => '', 'imageurl' => '', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $products = array(); $setting = array_merge($t, $setting); $language_id = Context::getContext()->language->id; $setting['description'] = isset($setting['description_' . $language_id]) ? $setting['description_' . $language_id] : ''; switch ($setting['list_type']) { case 'newest': $products = self::getNewProducts($setting['categoryBox'], $this->lang_id, 0, (int) $setting['limit']); $setting['link_to_all'] = Context::getContext()->link->getPageLink('new-products'); break; case 'featured': $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id); $nb = (int) $setting['limit']; $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8); break; case 'bestseller': $products = self::getBestSalesLight($setting['categoryBox'], (int) $this->lang_id, 0, (int) $setting['limit']); $setting['link_to_all'] = Context::getContext()->link->getPageLink('best-sales'); break; case 'special': $products = self::getPricesDrop($setting['categoryBox'], $this->lang_id, 0, (int) $setting['limit']); $setting['link_to_all'] = Context::getContext()->link->getPageLink('prices-drop'); break; case 'toprating': $products = self::getProducts($setting['categoryBox'], 0, (int) $setting['limit']); break; } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); if ($setting['banner_imagefile']) { $setting['bannerurl'] = _PAGEBUILDER_IMAGE_URL_ . $setting['banner_imagefile']; } $language_id = Context::getContext()->language->id; $setting['sub_title'] = isset($setting['sub_title_' . $language_id]) ? $setting['sub_title_' . $language_id] : ''; $setting['products'] = $products; $output = array('type' => 'products', 'data' => $setting); return $output; }
/** * get list of Sliders Data following parameter */ public function getData($params) { global $link, $cookie; $nb = (int) $params->get("limit", 10); switch ($params->get('psmode', 'featured')) { case 'newest': $products = Product::getNewProducts((int) $cookie->id_lang, 0, $nb); break; case 'special': $products = Product::getPricesDrop($this->context->language->id, null, $nb, true); break; case 'featured': default: $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb); break; } $iwidth = $params->get('imgwidth', 960); $iheight = $params->get('imgheight', 360); $twidth = $params->get('thumbwidth', 160); $theight = $params->get('thumbheight', 90); $output = array(); foreach ($products as $i => $product) { $output[] = array('id_slide' => $product['id_product'], 'image' => $link->getImageLink($product["link_rewrite"], $product["id_image"]), 'title' => $product['name'], 'url' => $product['link'], 'oimage' => '', 'thumb' => '', 'legend' => '', 'description' => $product['description_short'], 'category' => $product['category'], 'price' => $product['price'], 'price_tax_exc' => $product['price_tax_exc'], 'attribute_price' => $product['attribute_price'], 'price_without_reduction' => $product['price_without_reduction'], 'manufacturer' => $product['manufacturer_nam']); $output[$i]['thumbnail'] = $output[$i]['image']; $output[$i]['mainimage'] = $output[$i]['image']; if ($params->get('cropthumb', 1) && $output[$i]['image']) { $output[$i]['mainimage'] = $this->renderThumb($output[$i]['image'], $iwidth, $iheight); $output[$i]['thumbnail'] = $this->renderThumb($output[$i]['image'], $twidth, $theight); } // echo '<pre>'.print_r( $output, 1 ); die; } unset($products); // echo '<pre>'.print_r( $output, 1 ); die; return $output; }
/** * hook home to display generate the product list associated to home featured, news products and best sellers Modules */ public function hookHome() { $ga_scripts = ''; // Home featured products if ($this->isModuleEnabled('homefeatured')) { $category = new Category($this->context->shop->getCategory(), $this->context->language->id); $home_featured_products = $this->wrapProducts($category->getProducts((int) Context::getContext()->language->id, 1, Configuration::get('HOME_FEATURED_NBR') ? (int) Configuration::get('HOME_FEATURED_NBR') : 8, 'position'), array(), true); $ga_scripts .= $this->addProductImpression($home_featured_products) . $this->addProductClick($home_featured_products); } // New products if ($this->isModuleEnabled('blocknewproducts') && (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') || Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))) { $new_products = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR')); $new_products_list = $this->wrapProducts($new_products, array(), true); $ga_scripts .= $this->addProductImpression($new_products_list) . $this->addProductClick($new_products_list); } // Best Sellers if ($this->isModuleEnabled('blockbestsellers') && (!Configuration::get('PS_CATALOG_MODE') || Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))) { $ga_homebestsell_product_list = $this->wrapProducts(ProductSale::getBestSalesLight((int) $this->context->language->id, 0, 8), array(), true); $ga_scripts .= $this->addProductImpression($ga_homebestsell_product_list) . $this->addProductClick($ga_homebestsell_product_list); } $this->js_state = 1; return $this->_runJs($this->filter($ga_scripts)); }
function hookHome($params) { global $smarty; $category = new Category(1, Configuration::get('PS_LANG_DEFAULT')); $nb = (int) Configuration::get('HOME_FEATURED_NBR'); $products = $category->getProducts((int) $params['cookie']->id_lang, 1, $nb ? $nb : 10); $smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); }
public function _cacheProducts() { if (!isset(HomeFeatured::$cache_products)) { $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $nb = (int) Configuration::get('HOME_FEATURED_NBR'); HomeFeatured::$cache_products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb ? $nb : 8, 'position'); } if (HomeFeatured::$cache_products === false || empty(HomeFeatured::$cache_products)) { return false; } }
public function _cacheProducts() { if (!isset(HomeFeatured::$cache_products)) { $category = new Category((int) Configuration::get('HOME_FEATURED_CAT'), (int) Context::getContext()->language->id); $nb = (int) Configuration::get('HOME_FEATURED_NBR'); if (Configuration::get('HOME_FEATURED_RANDOMIZE')) { HomeFeatured::$cache_products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb ? $nb : 8, null, null, false, true, true, $nb ? $nb : 8); } else { HomeFeatured::$cache_products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb ? $nb : 8, 'position'); } } if (HomeFeatured::$cache_products === false || empty(HomeFeatured::$cache_products)) { return false; } }
public function hookDisplayFooter($params) { $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $nb = (int) Configuration::get('HOME_FEATURED_NBR'); $products = $category->getProducts((int) Context::getContext()->language->id, 1, 3); $this->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')))); return $this->display(__FILE__, 'tdhomefeatured-footer.tpl'); }
function productsInCategory($onAjax = FALSE) { $this->ident = Tools::getValue(!$onAjax ? 'id_category' : 'ident'); if ($this->ident > 0) { $category = new Category(); $category->id = $this->ident; $products = $category->getProducts($this->lang, 1, $category->getProducts($this->lang, 1, 1, NULL, NULL, TRUE)); $productIds = $productPrices = $productFinalPrices = $productPricesWT = array(); if ($products !== FALSE && count($products) > 0 && is_array($products)) { foreach ($products as $product) { $productIds[] = $product['id_product']; $productFinalPrices[] = $product['price']; $productInst = new Product($product['id_product'], TRUE, $this->lang); $this->productFinalPricesWT[] = $productInst->getPrice($this->inclTax); } } else { $productIds = $productPrices = $productFinalPrices = array(); } $this->idFinalPriceAssoc = $products != FALSE ? count($productIds) > 0 ? array_combine($productIds, $productFinalPrices) : array() : array(); $this->productIds = $productIds; sort($productPrices); $this->productFinalPrices = $productFinalPrices; } }
public function generateXML($cron) { $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__; $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $currency_default = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $this->currency_iso = $currency_default->iso_code; $country = new Country(Configuration::get('PS_COUNTRY_DEFAULT')); $this->country_name = $country->name; $currencies = Currency::getCurrencies(); $categories = Category::getCategories($id_lang, false, false); $yamarket_set_combinations = Configuration::get('YA_MARKET_SET_COMBINATIONS'); $this->yamarket_availability = Configuration::get('YA_MARKET_DOSTUPNOST'); $this->gzip = Configuration::get('YA_MARKET_SET_GZIP'); /*-----------------------------------------------------------------------------*/ $cats = array(); if ($c = Configuration::get('YA_MARKET_CATEGORIES')) { $uc = unserialize($c); if (is_array($uc)) { $cats = $uc; } } $yml = new Yml(); $yml->yml('utf-8'); $yml->setShop(Configuration::get('PS_SHOP_NAME'), Configuration::get('YA_MARKET_NAME'), $shop_url); if (Configuration::get('YA_MARKET_SET_ALLCURRENCY')) { foreach ($currencies as $currency) { $yml->addCurrency($currency['iso_code'], (double) $currency_default->conversion_rate / (double) $currency['conversion_rate']); } unset($currencies); } else { $yml->addCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate); } foreach ($categories as $category) { if (!in_array($category['id_category'], $cats) || $category['id_category'] == 1) { continue; } if (Configuration::get('YA_MARKET_SET_NACTIVECAT')) { if (!$category['active']) { continue; } } if (Configuration::get('YA_MARKET_CATALL')) { if (in_array($category['id_category'], $cats)) { $yml->addCategory($category['name'], $category['id_category'], $category['id_parent']); } } else { $yml->addCategory($category['name'], $category['id_category'], $category['id_parent']); } } foreach ($yml->categories as $cat) { $category_object = new Category($cat['id']); $products = $category_object->getProducts($id_lang, 1, 10000); if ($products) { foreach ($products as $product) { if ($product['id_category_default'] != $cat['id']) { continue; } $data = array(); if ($yamarket_set_combinations && !Configuration::get('YA_MARKET_SHORT')) { $product_object = new Product($product['id_product'], false, $id_lang); $combinations = $product_object->getAttributeCombinations($id_lang); } else { $combinations = false; } if (is_array($combinations) && count($combinations) > 0) { $comb_array = array(); foreach ($combinations as $combination) { $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute']; $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']); $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference']; $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13']; $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity']; $comb_array[$combination['id_product_attribute']]['minimal_quantity'] = $combination['minimal_quantity']; $comb_array[$combination['id_product_attribute']]['weight'] = $combination['weight']; $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name']; if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) { $comb_array[$combination['id_product_attribute']]['comb_url'] = ''; } $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . Tools::str2url($combination['group_name']) . '-' . str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::str2url(str_replace(array(',', '.'), '-', $combination['attribute_name']))); } foreach ($comb_array as $combination) { $data = $this->makeData($product, $combination); $available = $data['available']; unset($data['available']); if (!empty($data) && $data['price'] != 0) { $yml->addOffer($data['id'], $data, $available); } } } else { $data = $this->makeData($product); $available = $data['available']; unset($data['available']); if (!empty($data) && (int) $data['price'] != 0) { $yml->addOffer($data['id'], $data, $available); } } unset($data); } } unset($product); } unset($categories); $xml = $yml->getXml(); if ($cron) { if ($fp = fopen(_PS_UPLOAD_DIR_ . 'yml.' . $this->context->shop->id . '.xml' . ($this->gzip ? '.gz' : ''), 'w')) { fwrite($fp, $xml); fclose($fp); $this->logSave('market_generate: Cron ' . $this->l('Generate price')); } } else { if ($this->gzip) { header('Content-type:application/x-gzip'); header('Content-Disposition: attachment; filename=yml.' . $this->context->shop->id . '.xml.gz'); $this->logSave('market_generate: gzip view ' . $this->l('Generate price')); } else { header('Content-type:application/xml; charset=windows-1251'); } $this->logSave('market_generate: view ' . $this->l('Generate price')); echo $xml; exit; } }
public function generate($cron = false) { self::setCurrency(); include 'classes/ymlCatalog.php'; //Язык по умолчанию $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); //Валюта по умолчанию $currency_default = new Currency($this->context->cookie->id_currency); $this->currency_iso = $currency_default->iso_code; //Адрес магазина $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__; //Категории для экспорта $yamarket_с_categories = unserialize(Configuration::get('yamarket_с_categories')); //$yamarket_с_suppliers = unserialize(Configuration::get('yamarket_с_supplier')); $yamarket_с_combinations = Configuration::get('yamarket_с_combinations'); $this->yamarket_с_availability = Configuration::get('yamarket_с_availability'); $this->yamarket_с_shipping = unserialize(Configuration::get('yamarket_с_shipping')); //создаем новый магазин $catalog = new ymlCatalog(); $catalog->gzip = Configuration::get('yamarket_с_gzip'); $shop = new ymlShop(); $shop->name = Configuration::get('yamarket_с_shop'); $shop->company = Configuration::get('yamarket_с_company'); $shop->url = $shop_url; $shop->platform = 'PrestaShop'; $shop->version = _PS_VERSION_; $shop->agency = 'PrestaLab'; $shop->email = '*****@*****.**'; //Валюты $shop->startTag(ymlCurrency::$collectionName); if (Configuration::get('yamarket_с_currencies')) { $currencies = Currency::getCurrencies(); foreach ($currencies as $currency) { $shop->add(new ymlCurrency($currency['iso_code'], (double) $currency['conversion_rate'])); } unset($currencies); } else { $shop->add(new ymlCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate)); } $shop->endTag(ymlCurrency::$collectionName); //Категории $categories = Category::getCategories($id_lang, false, false); $shop->startTag(ymlCategory::$collectionName); foreach ($categories as $category) { if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) { $shop->add(new ymlCategory($category['id_category'], $category['name'], $category['id_parent'])); } } $shop->endTag(ymlCategory::$collectionName); //Стоимость доставки $shop->addString('<local_delivery_cost>' . Configuration::get('yamarket_с_shippingcost') . '</local_delivery_cost>'); //Товары $shop->startTag(ymlOffer::$collectionName); foreach ($categories as $category) { if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) { $category_object = new Category($category['id_category']); $products = $category_object->getProducts($id_lang, 1, 10000); if ($products) { foreach ($products as $product) { if ($product['id_category_default'] != $category['id_category']) { continue; } // if (count($yamarket_с_suppliers)&&(!in_array($product['id_supplier'], $yamarket_с_suppliers))) // continue; //Для комбинаций if ($yamarket_с_combinations) { $product_object = new Product($product['id_product'], false, $id_lang); $combinations = $product_object->getAttributeCombinations($id_lang); } else { $combinations = false; } if (is_array($combinations) && count($combinations) > 0) { $comb_array = array(); foreach ($combinations as $combination) { $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute']; $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']); $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference']; $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13']; $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity']; $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name']; $comb_array[$combination['id_product_attribute']]['oldprice'] = $product['orderprice'] + $combination['price']; if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) { $comb_array[$combination['id_product_attribute']]['comb_url'] = ''; } $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . (self::combinationUrlPrepare($combination['group_name']) . '-' . self::combinationUrlPrepare($combination['attribute_name'])); } foreach ($comb_array as $combination) { self::_addProduct($shop, $product, $combination); } } else { self::_addProduct($shop, $product); } } } unset($product); } } unset($categories); $shop->endTag(ymlOffer::$collectionName); $catalog->add($shop); if ($cron) { if ($fp = fopen(_PS_UPLOAD_DIR_ . 'yml.' . $this->context->shop->id . '.xml' . ($catalog->gzip ? '.gz' : ''), 'w')) { fwrite($fp, $catalog->generate()); fclose($fp); } } else { if ($catalog->gzip) { header('Content-type:application/x-gzip'); header('Content-Disposition: attachment; filename=yml.' . $this->context->shop->id . '.xml.gz'); } else { header('Content-type:application/xml; charset=utf-8'); } echo $catalog->generate(); } }
} else { $last_page = (int) ($countProducts / 9) + 1; } if (isset($_GET['page']) && $_GET['page'] > 0 && $_GET['page'] <= $last_page) { $min = ($_GET['page'] - 1) * 9 + 1; $max = $_GET['page'] * 9; if ($max > $countProducts) { $pagination = 'Produit ' . $min . ' à ' . $countProducts . ' sur ' . $countProducts; } else { $pagination = 'Produit ' . $min . ' à ' . $max . ' sur ' . $countProducts; } } else { $pagination = 'Produit 1 à 9 sur ' . $countProducts; $_GET['page'] = 1; } $products = $category->getProducts($_GET['page'], 'prix', $brandArray, $priceArray); // $products = [1,2,3,4,5,6,7,8,9,10,11,12]; $i = 0; foreach ($products as $product) { if ($i == 0) { echo '<ul class="products-grid first odd">'; echo ' <li class="item first fadeIn animated"> <a class="product-image" title="' . $product['libelle_produit'] . '" href="product.php?idProduit=' . $product['id_produit'] . '"><div class="image_gallery" style="width:249px;height:200px;line-height:200px;overflow:hidden;"><center><img style="vertical-align : middle;" src="media/' . $product['nom_photo'] . '.jpg" alt="product"></div></a> <h2 class="product-name"> <a title="' . $product['libelle_produit'] . '" href="product.php?idProduit=' . $product['id_produit'] . '"> ' . $product['libelle_produit'] . ' </a> </h2> <div class="actions"> <a class="btn-circle"> <i class="icon-heart"></i> </a> <a class="btn-circle" type="cart" idProduit="' . $product['id_produit'] . '"> <i class="icon-shopping-cart"></i> </a>
public function renderContent($args, $setting) { # validate module unset($args); $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6; $orderby = $setting['orderby'] ? $setting['orderby'] : 'date_add'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC'; $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3; $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3; $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000; switch ($setting['source']) { case 'ptype': switch ($setting['ptype']) { case 'newest': $products = Product::getNewProducts($this->langID, 0, $nb, false, $orderby, $orderway); break; case 'featured': $category = new Category(Context::getContext()->shop->getCategory(), $this->langID); $products = $category->getProducts((int) $this->langID, 1, $nb, $orderby, $orderway); break; case 'bestseller': $products = ProductSale::getBestSalesLight((int) $this->langID, 0, $nb); break; case 'special': $products = Product::getPricesDrop($this->langID, 0, $nb, false, $orderby, $orderway); break; case 'random': $random = true; $products = $this->getProducts('WHERE p.id_product > 0', (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway, false, true, $random, $nb); Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1'); break; } break; case 'pproductids': $where = ''; if (empty($setting['pproductids'])) { return false; } if ($pproductids = $setting['pproductids']) { $where = 'WHERE p.id_product IN (' . pSQL($pproductids) . ')'; } $products = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); break; case 'pcategories': $where = ''; $catids = isset($setting['categories']) && $setting['categories'] ? $setting['categories'] : array(); $products = array(); if ($catids) { $categorys = implode(',', $catids); $where = 'WHERE cp.id_category IN (' . pSQL($categorys) . ')'; $products = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); } break; case 'pmanufacturers': $where = ''; $manufacturers = $setting['pmanufacturer'] ? $setting['pmanufacturer'] : array(); if ($manufacturers) { $manufacturers = implode(',', $manufacturers); $where = 'WHERE p.id_manufacturer IN (' . pSQL($manufacturers) . ')'; } $products = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); break; } Context::getContext()->controller->addColorsToProductList($products); $setting['products'] = $products; $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['scolumn'] = 12 / $columns_page; $setting['interval'] = $interval; $setting['homeSize'] = Image::getSize(ImageType::getFormatedName('home')); $setting['tab'] = 'leoproductcarousel' . rand(20, rand()); $output = array('type' => 'carousel', 'data' => $setting); return $output; }