Пример #1
0
 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nb_products = (int) ProductSale::getNbSales();
         $this->pagination($nb_products);
         if (!Tools::getValue('orderby')) {
             $this->orderBy = 'sales';
         }
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $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' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
Пример #2
0
 public function __construct()
 {
     $this->name = 'groupcategory';
     //$this->cache = new GroupCategoryFastCache();
     $this->arrType = array('saller' => $this->l('Best Sellers'), 'view' => $this->l('Most View'), 'special' => $this->l('Specials'), 'arrival' => $this->l('New Arrivals'));
     $this->secure_key = Tools::encrypt('ovic-soft[group-category]' . $this->name);
     $this->imageHomeSize = Image::getSize(ImageType::getFormatedName('home'));
     $this->arrLayout = array('default' => $this->l('Layout [default]'));
     $this->pathTemp = dirname(__FILE__) . '/images/temps/';
     $this->pathBanner = dirname(__FILE__) . '/images/banners/';
     $this->pathIcon = dirname(__FILE__) . '/images/icons/';
     if (Configuration::get('PS_SSL_ENABLED')) {
         $this->livePath = _PS_BASE_URL_SSL_ . __PS_BASE_URI__ . 'modules/groupcategory/images/';
     } else {
         $this->livePath = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/groupcategory/images/';
     }
     $this->tab = 'front_office_features';
     $this->version = '1.0';
     $this->author = 'OvicSoft';
     $this->bootstrap = true;
     parent::__construct();
     $this->displayName = $this->l('Supershop - Group Category Module');
     $this->description = $this->l('Group Category Module');
     $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
 }
 /**
  * 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');
     }
 }
Пример #4
0
 public function setProduct($product, $combination)
 {
     // create the product
     $context = Context::getContext();
     $this->give_it_product = new GiveItSdkProduct();
     $this->give_it_product->setCurrency($context->currency->iso_code);
     $usetax = Product::getTaxCalculationMethod((int) $context->customer->id) != PS_TAX_EXC;
     if ($combination['id_product_attribute'] == 0) {
         $combination['attributes'] = '';
         $image = Product::getCover($product->id);
     } else {
         $comb = new Combination($combination['id_product_attribute']);
         if ($image = $comb->getWsImages()) {
             $image = $image[0];
             $image['id_image'] = $image['id'];
         }
     }
     $image['id_product'] = $product->id;
     $image['id_image'] = Product::defineProductImage($image, Context::getContext()->language->id);
     $img_profile = version_compare(_PS_VERSION_, '1.5', '<') ? 'home' : ImageType::getFormatedName('medium');
     $image = $image ? $context->link->getImageLink($product->link_rewrite, $image['id_image'], $img_profile) : '';
     // first, set the product details.
     $this->give_it_product->setProductDetails(array('code' => $product->id . '_' . $combination['id_product_attribute'], 'price' => (int) (Product::getPriceStatic((int) $product->id, $usetax, $combination['id_product_attribute']) * 100), 'name' => $product->name . ($combination['attributes'] ? ' : ' . $combination['attributes'] : ''), 'image' => $image));
     $delivery = $this->setDelivery();
     // add the delivery option to the product
     $this->give_it_product->addBuyerOption($delivery);
     //We should validate this product
     $this->product_valid = $this->give_it_product->validate();
 }
Пример #5
0
 public function __construct()
 {
     $this->name = 'flexiblebrands';
     $this->imageHomeSize = Image::getSize(ImageType::getFormatedName('home'));
     $this->orderValue = array('sales' => $this->l('Sales'), 'price' => $this->l('Price'), 'discount' => $this->l('Discount'), 'add' => $this->l('Add Date'), 'rand' => $this->l('Random'));
     $this->orderType = array('asc' => $this->l('Ascending'), 'desc' => $this->l('Descending'));
     $this->display = array('all' => $this->l('All'), 'condition-new' => $this->l('New'), 'condition-used' => $this->l('Used'), 'condition-refurbished' => $this->l('Refurbished'));
     $this->groupType = array('auto' => $this->l('Auto'), 'manual' => $this->l('Manual'));
     $this->moduleLayout = array('default' => $this->l('Layout [default]'));
     $this->tempPath = dirname(__FILE__) . '/images/temps/';
     $this->bannerPath = dirname(__FILE__) . '/images/banners/';
     $this->iconPath = dirname(__FILE__) . '/images/icons/';
     if (Configuration::get('PS_SSL_ENABLED')) {
         $this->livePath = _PS_BASE_URL_SSL_ . __PS_BASE_URI__ . 'modules/flexiblebrands/images/';
     } else {
         $this->livePath = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/flexiblebrands/images/';
     }
     $this->secure_key = Tools::encrypt('ovic-' . $this->name);
     $this->tab = 'front_office_features';
     $this->version = '1.0';
     $this->author = 'OvicSoft [SonNC]';
     $this->bootstrap = true;
     parent::__construct();
     $this->displayName = $this->l('Ovic Flexible Brands Module');
     $this->description = $this->l('Ovic Flexible Brands Module');
     $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
     //$this->cache = new FlexibleBrandFastCache();
 }
Пример #6
0
 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');
 }
 protected static function generateImageLink($product, $ps_product, $id_lang, $iso_code)
 {
     $link = new Link();
     $cover = Image::getCover($ps_product->id);
     $product->{"image_link_small_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("small"));
     $product->{"image_link_large_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("large"));
     return $product;
 }
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = (int) ProductSale::getNbSales();
     $this->pagination($nbProducts);
     $this->context->smarty->assign(array('products' => ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
 }
Пример #9
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $original_query = Tools::getValue('q');
     $query = Tools::replaceAccentedChars(urldecode($original_query));
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         if (is_array($searchResults)) {
             foreach ($searchResults as &$product) {
                 $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
             }
             Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults)));
         }
         $this->ajaxDie(Tools::jsonEncode($searchResults));
     }
     //Only controller content initialization when the user use the normal search
     parent::initContent();
     $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int) $this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE');
     if ($this->instant_search && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         if (is_array($search['result'])) {
             foreach ($search['result'] as &$product) {
                 $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
             }
         }
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
         $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
         $this->addColorsToProductList($result);
         $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } else {
         $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl');
 }
Пример #10
0
 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id'];
             $productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id'];
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         /**
          * ABU edit: variable is_discount set à 1 à tord, calcul foireux de presta
          * @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23
          * @perso: soustraction de l'ecotax au price_without_specific_price @else
          */
         if (Product::getTaxCalculationMethod()) {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
Пример #11
0
 public function hookDisplayHomeLine5($params)
 {
     if (!$this->isCached('blockbestsellershome.tpl', $this->getCacheId('blockbestsellershome'))) {
         $this->smarty->assign(array('best_sellers' => BlockBestSellers::$cache_best_sellers, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     }
     if (BlockBestSellers::$cache_best_sellers === false) {
         return false;
     }
     return $this->display(__FILE__, 'blockbestsellershome.tpl', $this->getCacheId('blockbestsellershome'));
 }
Пример #12
0
 public function hookRightColumn($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     if (!($special = Product::getRandomSpecial((int) $params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) {
         return;
     }
     $this->smarty->assign(array('special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium'))));
     return $this->display(__FILE__, 'blockspecials.tpl');
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getPricesDrop($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'prices-drop.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, 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');
 }
 protected function formatProduct($id_product, $id_lang)
 {
     $link = new Link();
     $product = new Product($id_product, true, $id_lang);
     $category = new Category($product->id_category_default, $id_lang);
     $product->objectID = $product->id;
     $product->category = $category->name;
     $product->url = $link->getProductLink($product->id);
     /* Cover */
     $cover = Image::getCover($product->id);
     $product->image_link_small = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('small'));
     $product->image_link_large = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('large'));
     return $product;
 }
Пример #16
0
 public function hookDisplayHome($params)
 {
     if (!$this->isCached('tmbrandlogo.tpl', $this->getCacheId())) {
         $manufacturers = Manufacturer::getManufacturers();
         foreach ($manufacturers as &$manufacturer) {
             $manufacturer['image'] = $this->context->language->iso_code . '-default';
             if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
                 $manufacturer['image'] = $manufacturer['id_manufacturer'];
             }
         }
         $this->smarty->assign(array('manufacturers' => $manufacturers, 'tm_slider' => Configuration::get('TM_BRAND_SLIDER'), 'tm_logoname' => Configuration::get('TM_BRAND_NAME'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'tmbrandlogo.tpl', $this->getCacheId());
 }
Пример #17
0
 public function hookLeftColumn($params)
 {
     if (!$this->isCached('blockmanufacturer.tpl', $this->getCacheId())) {
         $manufacturers = Manufacturer::getManufacturers();
         foreach ($manufacturers as &$manufacturer) {
             $manufacturer['image'] = $this->context->language->iso_code . '-default';
             if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
                 $manufacturer['image'] = $manufacturer['id_manufacturer'];
             }
         }
         $this->smarty->assign(array('manufacturers' => $manufacturers, 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('MANUFACTURER_DISPLAY_FORM'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'blockmanufacturer.tpl', $this->getCacheId());
 }
Пример #18
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $data = Manufacturer::getManufacturers(false, 0, true, 1, $setting['limit']);
     foreach ($data as $key => $item) {
         $item['image'] = !file_exists(_PS_MANU_IMG_DIR_ . $item['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? Context::getContext()->language->iso_code . '-default' : $item['id_manufacturer'];
         $data[$key] = $item;
     }
     $setting['manufacturers'] = $data;
     $setting['link'] = Context::getContext()->link;
     $output = array('type' => 'manufacture', 'data' => $setting);
     return $output;
 }
Пример #19
0
 public function processData()
 {
     if (Module::isInstalled('agilemultipleshop') && Shop::$id_shop_owner > 0) {
         if (!Validate::isLoadedObject($this->seller)) {
             $this->errors[] = Tools::displayError('Seller does not exist');
         } elseif (!$this->seller->active) {
             self::$smarty->assign('seller', $this->seller);
         } else {
             $rewrited_url = self::$link->getAgileSellerLink((int) $this->seller->id, $this->getSellerLinkRwrite());
             $this->seller_info->description = _PS_VERSION_ > '1.5' ? Tools::nl2br($this->seller_info->description) : nl2br2($this->seller_info->description);
             self::$smarty->assign('seller', $this->seller);
             self::$smarty->assign('seller_info', $this->seller_info);
             $sellermodule = new AgileMultipleSeller();
             $conf = Configuration::getMultiple($sellermodule->getCustomFields());
             $custom_labels = $sellermodule->getCustomLabels();
             self::$smarty->assign('conf', $conf);
             self::$smarty->assign('custom_labels', $custom_labels);
             $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
             $this->pagination((int) $nbProducts);
             self::$smarty->assign('nb_products', (int) $nbProducts);
             $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
             AgileHelper::AssignProductImgs($seller_products);
             $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">=");
             $HOOK_SELLER_RATINGS = '';
             if (Module::isInstalled('agilesellerratings')) {
                 require_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php";
                 $rmodule = new AgileSellerRatings();
                 $HOOK_SELLER_RATINGS = $rmodule->getAverageRating($this->id_seller, AgileSellerRatings::RATING_TYPE_SELLER);
             }
             self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'id_seller' => (int) $this->seller->id, 'path' => $this->seller_info->company, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . "/modules/agilesellerproducts/", 'agilemultipleshop_tpl' => _PS_ROOT_DIR_ . "/modules/agilemultipleshop/", 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'HOOK_SELLER_RATINGS' => $HOOK_SELLER_RATINGS, 'page_name' => 'agileseller'));
             $ver = (int) str_replace(".", "", _PS_VERSION_);
             if ($ver <= 1430) {
             } else {
                 if ($ver <= 1451) {
                     if (isset(self::$cookie->id_customer)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer));
                     } elseif (isset(self::$cookie->id_guest)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest));
                     }
                 } else {
                     if (isset(self::$cookie->id_compare)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare));
                     }
                 }
             }
         }
         self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
     }
 }
 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nbProducts = (int) ProductSale::getNbSales();
         $this->pagination($nbProducts);
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
         $this->addColorsToProductList($products);
         $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
         $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
Пример #21
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;
 }
Пример #22
0
 public function processData()
 {
     $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
     $this->pagination((int) $nbProducts);
     self::$smarty->assign('nb_products', (int) $nbProducts);
     $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
     AgileHelper::AssignProductImgs($seller_products);
     $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">=");
     include_once _PS_ROOT_DIR_ . "/modules/agilemultipleshop/agilemultipleshop.php";
     $module = new AgileMultipleShop();
     self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'id_location' => $this->id_location, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . '/modules/' . (_PS_VERSION_ > '1.5' ? 'agilemultipleshop' : 'agilesellerproducts') . '/', 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'path' => $module->getL('Shop By Location')));
     $ver = (int) str_replace(".", "", _PS_VERSION_);
     if (isset(self::$cookie->id_compare)) {
         self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare));
     }
     self::$smarty->assign(array('seller_locations4page' => agilemultipleshop::getLocationListNV($this->location_level), 'location_level4page' => $this->location_level));
     self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM')));
 }
Пример #23
0
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getPricesDrop($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     if (method_exists('Product', 'getProductsImgs')) {
         $image_array = array();
         for ($i = 0; $i < $nbProducts; $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);
     }
     $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'prices-drop.tpl');
 }
Пример #24
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'html' => '', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1, 'widgetid' => 'manu-' . time());
     $setting = array_merge($t, $setting);
     $manufacturers = Manufacturer::getManufacturers();
     foreach ($manufacturers as &$manufacturer) {
         $manufacturer['image'] = Context::getContext()->language->iso_code . '-default';
         if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
             $manufacturer['image'] = $manufacturer['id_manufacturer'];
         }
     }
     $setting['manufacturers'] = $manufacturers;
     $list_mode_tpl = _PS_MODULE_DIR_ . '/pspagebuilder/views/templates/front/widgets/sub/item_manufacturer_' . $setting['list_mode'] . '.tpl';
     $tlist_mode_tpl = _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/modules/pspagebuilder/views/templates/front/widgets/sub/item_manufacturer_' . $setting['list_mode'] . '.tpl';
     if (file_exists($tlist_mode_tpl)) {
         $list_mode_tpl = $tlist_mode_tpl;
     }
     $setting['list_mode_tpl'] = $list_mode_tpl;
     $output = array('type' => 'manufacturer', 'data' => $setting);
     return $output;
 }
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     $nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getPricesDrop($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' => $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');
         $pagination_bottom = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination_bottom.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, 'pagination_bottom' => $pagination_bottom, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
         die;
     } else {
         $this->setTemplate(_PS_THEME_DIR_ . 'prices-drop.tpl');
     }
 }
Пример #26
0
    private function _initConfig()
    {
        //Avoid servers IPs
        Db::getInstance()->Execute('
			CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'customer_ip` (
			`id_customer_ip` int(10) unsigned NOT null AUTO_INCREMENT,
			`id_customer` int(10) unsigned NOT null,
			`ip` varchar(32) DEFAULT null,
			PRIMARY KEY (`id_customer_ip`),
			KEY `idx_id_customer` (`id_customer`)
			) ENGINE=' . _MYSQL_ENGINE_ . '  DEFAULT CHARSET=utf8;');
        if (version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive()) {
            foreach (Shop::getShops() as $shop) {
                if (!Configuration::updateValue('SHOPPING_FLUX_TOKEN', md5(rand()), false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_CANCELED', Configuration::get('PS_OS_CANCELED'), false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_SHIPPED', Configuration::get('PS_OS_SHIPPING'), false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_IMAGE', ImageType::getFormatedName('large'), false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_CARRIER', Configuration::get('PS_CARRIER_DEFAULT'), false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_TRACKING', 'checked', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_BUYLINE', 'checked', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_ORDERS', 'checked', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_STATUS_SHIPPED', 'checked', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_STATUS_CANCELED', '', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_LOGIN', '', false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_INDEX', 'http://' . $shop['domain'] . $shop['uri'], false, null, $shop['id_shop']) || !Configuration::updateValue('SHOPPING_FLUX_STOCKS', '', false, null, $shop['id_shop'])) {
                    return false;
                }
            }
        } else {
            if (!Configuration::updateValue('SHOPPING_FLUX_TOKEN', md5(rand())) || !Configuration::updateValue('SHOPPING_FLUX_CANCELED', Configuration::get('PS_OS_CANCELED')) || !Configuration::updateValue('SHOPPING_FLUX_SHIPPED', Configuration::get('PS_OS_SHIPPING')) || !Configuration::updateValue('SHOPPING_FLUX_IMAGE', ImageType::getFormatedName('large')) || !Configuration::updateValue('SHOPPING_FLUX_CARRIER', Configuration::get('PS_CARRIER_DEFAULT')) || !Configuration::updateValue('SHOPPING_FLUX_TRACKING', 'checked') || !Configuration::updateValue('SHOPPING_FLUX_BUYLINE', 'checked') || !Configuration::updateValue('SHOPPING_FLUX_ORDERS', 'checked') || !Configuration::updateValue('SHOPPING_FLUX_STATUS_SHIPPED', 'checked') || !Configuration::updateValue('SHOPPING_FLUX_STATUS_CANCELED', '') || !Configuration::updateValue('SHOPPING_FLUX_LOGIN', '') || !Configuration::updateValue('SHOPPING_FLUX_INDEX', 'http://' . $shop['domain'] . $shop['uri']) || !Configuration::updateValue('SHOPPING_FLUX_STOCKS')) {
                return false;
            }
        }
        return true;
    }
 public function initContent()
 {
     if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         parent::initContent();
         $this->productSort();
         $nbProducts = (int) ProductSale::getNbSales();
         $this->pagination($nbProducts);
         $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $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' => $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_ . 'best-sales.tpl');
         }
     } else {
         Tools::redirect('index.php?controller=404');
     }
 }
Пример #28
0
 /**
  * Assigns scenes template variables
  */
 protected function assignScenes()
 {
     // Scenes (could be externalised to another controller if you need them)
     $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false);
     $this->context->smarty->assign('scenes', $scenes);
     // Scenes images formats
     if ($scenes && ($scene_image_types = ImageType::getImagesTypes('scenes'))) {
         foreach ($scene_image_types as $scene_image_type) {
             if ($scene_image_type['name'] == ImageType::getFormatedName('m_scene')) {
                 $thumb_scene_image_type = $scene_image_type;
             } elseif ($scene_image_type['name'] == ImageType::getFormatedName('scene')) {
                 $large_scene_image_type = $scene_image_type;
             }
         }
         $this->context->smarty->assign(array('thumbSceneImageType' => isset($thumb_scene_image_type) ? $thumb_scene_image_type : null, 'largeSceneImageType' => isset($large_scene_image_type) ? $large_scene_image_type : null));
     }
 }
Пример #29
0
    public static function getCrossSells($id_product, $id_lang, $limit = 12)
    {
        if (!$id_product || !$id_lang) {
            return;
        }
        $front = true;
        if (!in_array(Context::getContext()->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT o.id_order
		FROM ' . _DB_PREFIX_ . 'orders o
		LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
		WHERE o.valid = 1 AND od.product_id = ' . (int) $id_product);
        if (count($orders)) {
            $list = '';
            foreach ($orders as $order) {
                $list .= (int) $order['id_order'] . ',';
            }
            $list = rtrim($list, ',');
            $order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT DISTINCT od.product_id, p.id_product, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
				cl.link_rewrite category, p.ean13, p.out_of_stock, p.id_category_default ' . (Combination::isFeatureActive() ? ', IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute' : '') . '
				FROM ' . _DB_PREFIX_ . 'order_detail od
				LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
				' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop
				ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop=' . (int) Context::getContext()->shop->id . ')' : '') . '
				LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
				WHERE od.id_order IN (' . $list . ')
					AND pl.id_lang = ' . (int) $id_lang . '
					AND cl.id_lang = ' . (int) $id_lang . '
					AND od.product_id != ' . (int) $id_product . '
					AND i.cover = 1
					AND product_shop.active = 1' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
				ORDER BY RAND()
				LIMIT ' . (int) $limit . '
			', true, false);
            $tax_calc = Product::getTaxCalculationMethod();
            if (is_array($order_products)) {
                foreach ($order_products as &$order_product) {
                    $order_product['image'] = Context::getContext()->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('medium'));
                    $order_product['link'] = Context::getContext()->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
                    if ($tax_calc == 0 || $tax_calc == 2) {
                        $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
                    } elseif ($tax_calc == 1) {
                        $order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
                    }
                }
                return Product::getProductsProperties($id_lang, $order_products);
            }
        }
    }
Пример #30
0
 /**
  * Assign template vars related to images
  */
 protected function assignImages()
 {
     $images = $this->product->getImages((int) $this->context->cookie->id_lang);
     $product_images = array();
     if (isset($images[0])) {
         $this->context->smarty->assign('mainImage', $images[0]);
     }
     foreach ($images as $k => $image) {
         if ($image['cover']) {
             $this->context->smarty->assign('mainImage', $image);
             $cover = $image;
             $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
             $cover['id_image_only'] = (int) $image['id_image'];
         }
         $product_images[(int) $image['id_image']] = $image;
     }
     if (!isset($cover)) {
         if (isset($images[0])) {
             $cover = $images[0];
             $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $images[0]['id_image'] : $images[0]['id_image'];
             $cover['id_image_only'] = (int) $images[0]['id_image'];
         } else {
             $cover = array('id_image' => $this->context->language->iso_code . '-default', 'legend' => 'No picture', 'title' => 'No picture');
         }
     }
     $size = Image::getSize(ImageType::getFormatedName('large'));
     $this->context->smarty->assign(array('have_image' => isset($cover['id_image']) && (int) $cover['id_image'] ? array((int) $cover['id_image']) : Product::getCover((int) Tools::getValue('id_product')), 'cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'largeSize' => Image::getSize(ImageType::getFormatedName('large')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'cartSize' => Image::getSize(ImageType::getFormatedName('cart')), 'col_img_dir' => _PS_COL_IMG_DIR_));
     if (count($product_images)) {
         $this->context->smarty->assign('images', $product_images);
     }
 }