function hookHome($params)
 {
     global $smarty;
     $products = Product::getNewProducts((int) $params['cookie']->id_lang, 0, 5);
     $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home')));
     return $this->display(__FILE__, 'blocknewestproducts.tpl');
 }
 function hookRightColumn($params)
 {
     global $smarty;
     $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, intval(Configuration::get('NEW_PRODUCTS_NBR')));
     $smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blocknewproducts.tpl');
 }
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     // Override default configuration values: cause the new products page must display latest products first.
     if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
         $this->orderBy = 'date_add';
         $this->orderWay = 'DESC';
     }
     $nb_products = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
     $this->pagination($nb_products);
     $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     /************************* /Images Array ******************************/
     if (method_exists('Product', 'getProductsImgs')) {
         $image_array = array();
         for ($i = 0; $i < $nb_products; $i++) {
             if (isset($products[$i]['id_product'])) {
                 $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
             }
         }
         $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
     }
     /************************* /Images Array ******************************/
     $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     // Override default configuration values: cause the new products page must display latest products first.
     if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
         $this->orderBy = 'date_add';
         $this->orderWay = 'DESC';
     }
     $nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     if ($this->ajax) {
         $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
         $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
         $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
         $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
         echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
         die;
     } else {
         $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
     }
 }
Example #5
0
 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 process()
 {
     parent::process();
     $this->productSort();
     $nbProducts = (int) Product::getNewProducts((int) self::$cookie->id_lang, isset($this->p) ? (int) $this->p - 1 : NULL, isset($this->n) ? (int) $this->n : NULL, true);
     $this->pagination($nbProducts);
     self::$smarty->assign(array('products' => Product::getNewProducts((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize('home')));
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
     $this->pagination($nbProducts);
     $this->context->smarty->assign(array('products' => Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
 }
Example #8
0
 public function displayMain()
 {
     global $smarty;
     $this->loadFilter();
     $products = Product::getNewProducts($this->p, $this->n, $this->by, $this->way);
     $this->pagination($products['total']);
     $smarty->assign(array('products' => $products['entitys']));
     return $smarty->fetch('new-products.tpl');
 }
Example #9
0
 function hookhome($params)
 {
     global $smarty;
     $newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
     if (!$newProducts and !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
         return;
     }
     $smarty->assign(array('new_products' => $newProducts, 'homeSize' => Image::getSize('home_default')));
     return $this->display(__FILE__, 'tdnewproducts.tpl');
 }
 private function getNewProducts()
 {
     if (!Configuration::get('NEW_PRODUCTS_NBR_TM')) {
         return;
     }
     $newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR_TM'));
     if (!$newProducts && Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
         return;
     }
     return $newProducts;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     // Override default configuration values: cause the new products page must display latest products first.
     if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
         $this->orderBy = 'date_add';
         $this->orderWay = 'DESC';
     }
     $nbProducts = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
     $this->pagination($nbProducts);
     $this->context->smarty->assign(array('products' => Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
 }
Example #12
0
 function hookRightColumn($params)
 {
     global $smarty;
     $currency = new Currency(intval($params['cookie']->id_currency));
     $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
     $new_products = array();
     if ($newProducts) {
         foreach ($newProducts as $newProduct) {
             $new_products[] = $newProduct;
         }
     }
     $smarty->assign(array('new_products' => $new_products, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blocknewproducts.tpl');
 }
Example #13
0
 protected function getNewProducts()
 {
     if (!Configuration::get('NEW_PRODUCTS_NBR')) {
         return;
     }
     $newProducts = false;
     if (Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) {
         $newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
     }
     if (!$newProducts && Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
         return;
     }
     return $newProducts;
 }
Example #14
0
 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;
 }
 /**
  * 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;
     }
 }
Example #16
0
 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;
 }
Example #17
0
 function hookRightColumn($params)
 {
     global $smarty, $category_path;
     $category_path_ids = array();
     foreach ($category_path as $cat) {
         $category_path_ids[] = $cat['id_category'];
     }
     $smarty->caching = 1;
     $cache_id = $category_path_ids[count($category_path_ids) - 1] . '-' . $params['cookie']->id_lang . '-' . $params['cookie']->id_currency;
     if (!$smarty->is_cached($this->find_template(__FILE__, 'blocknewproducts.tpl'), $cache_id)) {
         $currency = new Currency(intval($params['cookie']->id_currency));
         $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, 5 * Configuration::get('NEW_PRODUCTS_NBR'));
         $new_products = array();
         if ($newProducts) {
             $nr = 0;
             foreach ($newProducts as $newProduct) {
                 if ($nr >= Configuration::get('NEW_PRODUCTS_NBR')) {
                     break;
                 }
                 $display = false;
                 foreach (Product::getIndexedCategories($newProduct['id_product']) as $row) {
                     if (in_array($row['id_category'], $category_path_ids)) {
                         $display = true;
                         break;
                     }
                 }
                 if ($display) {
                     $new_products[] = $newProduct;
                     $nr += 1;
                 }
             }
         }
         $smarty->assign(array('new_products' => $new_products, 'mediumSize' => Image::getSize('medium')));
     }
     // End if not cached
     return $this->display(__FILE__, 'blocknewproducts.tpl', $cache_id);
 }
Example #18
0
 /**
  * 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;
 }
Example #19
0
<?php

include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/header.php';
include dirname(__FILE__) . '/product-sort.php';
$nbProducts = intval(Product::getNewProducts(intval($cookie->id_lang), isset($p) ? intval($p) - 1 : NULL, isset($n) ? intval($n) : NULL, true));
include dirname(__FILE__) . '/pagination.php';
$smarty->assign(array('products' => Product::getNewProducts(intval($cookie->id_lang), intval($p) - 1, intval($n), false, $orderBy, $orderWay), 'nbProducts' => intval($nbProducts)));
$smarty->display(_PS_THEME_DIR_ . 'new-products.tpl');
include dirname(__FILE__) . '/footer.php';
Example #20
0
 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;
 }
Example #21
0
 public function renderContent($args, $setting)
 {
     $t = array('ptype' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200');
     $products = array();
     $setting = array_merge($t, $setting);
     $orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
     $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
     $plimit = $setting['limit'] ? (int) $setting['limit'] : 6;
     switch ($setting['source']) {
         case 'ptype':
             switch ($setting['ptype']) {
                 case 'newest':
                     $products = Product::getNewProducts($this->langID, 0, $plimit);
                     break;
                 case 'featured':
                     $category = new Category(Context::getContext()->shop->getCategory(), $this->langID);
                     $nb = (int) $setting['limit'];
                     $products = $category->getProducts((int) $this->langID, 1, $plimit);
                     break;
                 case 'bestseller':
                     $products = ProductSale::getBestSalesLight((int) $this->langID, 0, $plimit);
                     break;
                 case 'special':
                     $products = Product::getPricesDrop($this->langID, 0, $plimit);
                     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, $plimit, $orderby, $orderway);
             break;
         case 'pcategories':
             $where = '';
             $catids = isset($setting['categories']) && $setting['categories'] ? $setting['categories'] : array();
             if ($catids) {
                 $categorys = implode(",", $catids);
                 $where = 'WHERE  cp.id_category IN  (' . pSQL($categorys) . ')';
             }
             $products = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $plimit, $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, $plimit, $orderby, $orderway);
             break;
     }
     Context::getContext()->controller->addColorsToProductList($products);
     $setting['products'] = $products;
     $output = array('type' => 'products', 'data' => $setting);
     return $output;
 }
 public function hookHome($params)
 {
     if (!$this->isCached('blocknewproducts-home.tpl', $this->getCacheId('blocknewproducts-home'))) {
         $newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
         if ($newProducts === false) {
             return;
         }
         $this->smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     }
     return $this->display(__FILE__, 'blocknewproducts-home.tpl', $this->getCacheId('blocknewproducts-home'));
 }
 public function hookRightColumn($params)
 {
     if (!$this->isCached('blocknewproducts.tpl', $this->getCacheId())) {
         if (!Configuration::get('NEW_PRODUCTS_NBR')) {
             return;
         }
         $newProducts = false;
         if (Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) {
             $newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
         }
         if (!$newProducts && !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
             return;
         }
         $this->smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium'))));
     }
     return $this->display(__FILE__, 'blocknewproducts.tpl', $this->getCacheId());
 }
Example #24
0
 /**
  * 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));
 }
Example #25
0
 public function buildSubmenuTree(array $dataset, $frontend = false, $cssgenerator = false)
 {
     $id_lang = (int) Context::getContext()->language->id;
     $id_shop = (int) Context::getContext()->shop->id;
     $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
     $tree = array();
     foreach ($dataset as $id => &$node) {
         if ($cssgenerator) {
             //set style
             if (isset($node['content_s']['br_top_st'])) {
                 $node['content_s']['br_top_st'] = $this->convertBorderType($node['content_s']['br_top_st']);
             }
             if (isset($node['content_s']['br_right_st'])) {
                 $node['content_s']['br_right_st'] = $this->convertBorderType($node['content_s']['br_right_st']);
             }
             if (isset($node['content_s']['br_bottom_st'])) {
                 $node['content_s']['br_bottom_st'] = $this->convertBorderType($node['content_s']['br_bottom_st']);
             }
             if (isset($node['content_s']['br_left_st'])) {
                 $node['content_s']['br_left_st'] = $this->convertBorderType($node['content_s']['br_left_st']);
             }
         }
         if ($frontend) {
             if (isset($node['content_s']['title'][$id_lang]) && $node['content_s']['title'][$id_lang] != '') {
                 $node['content_s']['title'] = $node['content_s']['title'][$id_lang];
             } elseif (isset($node['content_s']['title'][$id_lang_default]) && $node['content_s']['title'][$id_lang_default] != '') {
                 $node['content_s']['title'] = $node['content_s']['title'][$id_lang_default];
             } else {
                 unset($node['content_s']['title']);
             }
             if (isset($node['content_s']['href'][$id_lang]) && $node['content_s']['href'][$id_lang] != '') {
                 $node['content_s']['href'] = $node['content_s']['href'][$id_lang];
             } elseif (isset($node['content_s']['href'][$id_lang_default]) && $node['content_s']['href'][$id_lang_default] != '') {
                 $node['content_s']['href'] = $node['content_s']['href'][$id_lang_default];
             } else {
                 unset($node['content_s']['href']);
             }
             if (isset($node['content_s']['legend'][$id_lang]) && $node['content_s']['legend'][$id_lang] != '') {
                 $node['content_s']['legend'] = $node['content_s']['legend'][$id_lang];
             } elseif (isset($node['content_s']['legend'][$id_lang_default]) && $node['content_s']['legend'][$id_lang_default] != '') {
                 $node['content_s']['legend'] = $node['content_s']['legend'][$id_lang_default];
             } else {
                 unset($node['content_s']['legend']);
             }
             if (isset($node['tabtitle'][$id_lang]) && $node['tabtitle'][$id_lang] != '') {
                 $node['tabtitle'] = $node['tabtitle'][$id_lang];
             } elseif (isset($node['tabtitle'][$id_lang_default]) && $node['tabtitle'][$id_lang_default] != '') {
                 $node['tabtitle'] = $node['tabtitle'][$id_lang_default];
             } else {
                 unset($node['tabtitle']);
             }
             //set variouse links
             if (isset($node['contentType'])) {
                 switch ($node['contentType']) {
                     case 1:
                         if (isset($node['content']['ids'])) {
                             $customhtml = new IqitCreatorHtml((int) $node['content']['ids'], $id_lang);
                             if (Validate::isLoadedObject($customhtml)) {
                                 $node['content']['ids'] = $customhtml->html;
                             }
                         }
                         break;
                     case 4:
                         if (isset($node['content']['ids']) && !empty($node['content']['ids'])) {
                             $node['content']['products'] = Product::getProductsProperties($id_lang, $this->getProducts($node['content']['ids']));
                             $products = $node['content']['products'];
                             $this->addColorsToProductList($node['content']['products']);
                             if (method_exists('Product', 'getProductsImgs')) {
                                 $image_array = array();
                                 for ($i = 0; $i < count($products); $i++) {
                                     if (isset($products[$i]['id_product'])) {
                                         $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
                                     }
                                 }
                                 $node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL;
                             }
                             if ($node['content']['view'] == 1 || $node['content']['view'] == 3) {
                                 $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']);
                                 $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']);
                                 $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']);
                                 $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']);
                                 $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']);
                             }
                         }
                         break;
                     case 2:
                         if (isset($node['content']['ids'])) {
                             if ($node['content']['ids'] == 'n') {
                                 if ($node['content']['o'] == 1) {
                                     $products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit']);
                                 } else {
                                     $products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']);
                                 }
                             } elseif ($node['content']['ids'] == 's') {
                                 if ($node['content']['o'] == 1) {
                                     $products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit']);
                                 } else {
                                     $products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']);
                                 }
                             } elseif ($node['content']['ids'] == 'b') {
                                 $products = ProductSale::getBestSales($id_lang, 0, (int) $node['content']['limit'], 'sales');
                             } else {
                                 $category = new Category((int) $node['content']['ids'], $id_lang);
                                 if ($node['content']['o'] == 1) {
                                     $products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], null, null, false, true, true, (int) $node['content']['limit']);
                                 } else {
                                     $products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], $node['content']['o'], $node['content']['ob']);
                                 }
                             }
                             $node['content']['products'] = $products;
                             $this->addColorsToProductList($node['content']['products']);
                             if (method_exists('Product', 'getProductsImgs')) {
                                 $image_array = array();
                                 for ($i = 0; $i < count($products); $i++) {
                                     if (isset($products[$i]['id_product'])) {
                                         $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
                                     }
                                 }
                                 $node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL;
                             }
                             if ($node['content']['view'] == 1 || $node['content']['view'] == 3) {
                                 $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']);
                                 $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']);
                                 $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']);
                                 $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']);
                                 $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']);
                             }
                         }
                         break;
                     case 6:
                         if (isset($node['content']['source'][$id_lang]) && $node['content']['source'][$id_lang] != '') {
                             $node['content']['source'] = $node['content']['source'][$id_lang];
                         } elseif (isset($node['content']['source'][$id_lang_default]) && $node['content']['source'][$id_lang_default] != '') {
                             $node['content']['source'] = $node['content']['source'][$id_lang_default];
                         } else {
                             unset($node['content']['source']);
                         }
                         if (isset($node['content']['href'][$id_lang]) && $node['content']['href'][$id_lang] != '') {
                             $node['content']['href'] = $node['content']['href'][$id_lang];
                         } elseif (isset($node['content']['href'][$id_lang_default]) && $node['content']['href'][$id_lang_default] != '') {
                             $node['content']['href'] = $node['content']['href'][$id_lang_default];
                         } else {
                             unset($node['content']['href']);
                         }
                         break;
                     case 7:
                         if ($node['content']['view']) {
                             $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']);
                             $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']);
                             $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']);
                             $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']);
                             $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']);
                         }
                         break;
                     case 9:
                         $node['content']['module'] = $this->execModuleHook($node['content']['hook'], array(), $node['content']['id_module'], $id_shop);
                         break;
                 }
             }
         }
         if (!$frontend) {
             if (isset($node['contentType']) && $node['contentType'] == 4) {
                 if (isset($node['content']['ids']) && !empty($node['content']['ids'])) {
                     $node['content']['ids'] = $this->getProducts($node['content']['ids']);
                 }
             }
         }
         if ($node['parentId'] === 0) {
             $tree[$id] =& $node;
         } else {
             if (!isset($dataset[$node['parentId']]['children'])) {
                 $dataset[$node['parentId']]['children'] = array();
             }
             $dataset[$node['parentId']]['children'][$id] =& $node;
         }
     }
     $tree = $this->sortArrayTree($tree);
     return $tree;
 }
Example #26
0
 public function hookRightColumn($params)
 {
     global $smarty;
     $newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
     if (!$newProducts and !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
         return;
     }
     $smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blocknewproducts.tpl');
 }
Example #27
0
 private function getNewProducts()
 {
     if (!Configuration::get('NEW_PRODUCTS_NBR')) {
         //Тут по умолчанию присваивается 5, но выводится 20?
         return;
     }
     $newProducts = false;
     if (Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) {
         /*это как раз выводит новые товары  (слева)*/
         $newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
     }
     //echo ((int)Configuration::get('NEW_PRODUCTS_NBR'));8. Сколько поставишь, столько "Новых" товаров (начиная с самых новых)и выйдет
     //print_r($newProducts);
     //echo ('<br />');
     return $newProducts;
 }
 public function hookRightColumn($params)
 {
     global $smarty;
     $nb = intval(Configuration::get('NEW_PRODUCTS_NBR'));
     if (intval(Configuration::get('NEW_PRODUCTS_RANDOM'))) {
         $newProducts = $this->getNewProducts(intval($params['cookie']->id_lang), $nb ? $nb : 4, NULL, NULL, true, $nb ? $nb : 4);
     } else {
         $newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, $nb ? $nb : 4);
     }
     $smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blocknewproductz.tpl');
 }
Example #29
0
 public function hookDisplayHome()
 {
     if (!$this->isCached('posnewproduct.tpl', $this->getCacheId('posnewproduct'))) {
         $slideOptions = array('auto_slide' => Configuration::get($this->name . '_auto_slide'), 'speed_slide' => Configuration::get($this->name . '_speed_slide'), 'a_speed' => Configuration::get($this->name . '_a_speed'), 'show_price' => Configuration::get($this->name . '_show_price'), 'show_des' => Configuration::get($this->name . '_show_des'), 'qty_products' => Configuration::get($this->name . '_qty_products'), 'qty_items' => Configuration::get($this->name . '_qty_items'), 'width_item' => Configuration::get($this->name . '_width_item'), 'show_nexback' => Configuration::get($this->name . '_show_nextback'), 'show_control' => Configuration::get($this->name . '_show_control'), 'min_item' => Configuration::get($this->name . '_min_item'), 'max_item' => Configuration::get($this->name . '_max_item'), 'show_addtocart' => Configuration::get($this->name . '_show_addtocart'));
         // echo "<pre>"; print_r($slideOptions); die;
         $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id);
         $nb = (int) Configuration::get($this->name . '_qty_products');
         $products = Product::getNewProducts((int) Context::getContext()->language->id, 0, $nb ? $nb : 5);
         $this->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'slideOptions' => $slideOptions));
     }
     return $this->display(__FILE__, 'posnewproduct.tpl', $this->getCacheId('posnewproduct'));
 }