diff --git a/modules/expresscart/header2.tpl b/modules/expresscart/header2.tpl index c0dd23a9..fbcd449c 100644 --- a/modules/expresscart/header2.tpl +++ b/modules/expresscart/header2.tpl @@ -1,4 +1,5 @@ + + diff --git a/modules/privatesales_similarproducts/img/index.php b/modules/privatesales_similarproducts/img/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/privatesales_similarproducts/img/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/privatesales_similarproducts/img/logo.gif b/modules/privatesales_similarproducts/img/logo.gif new file mode 100755 index 00000000..86b4e900 Binary files /dev/null and b/modules/privatesales_similarproducts/img/logo.gif differ diff --git a/modules/privatesales_similarproducts/index.php b/modules/privatesales_similarproducts/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/privatesales_similarproducts/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/privatesales_similarproducts/it.php b/modules/privatesales_similarproducts/it.php new file mode 100755 index 00000000..7baf0291 --- /dev/null +++ b/modules/privatesales_similarproducts/it.php @@ -0,0 +1,24 @@ +blockbestsellers-home_3cb29f0ccc5fd220a97df89dafe46290'] = 'Migliori vendite'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers-home_d3da97e2d9aee5c8fbe03156ad051c99'] = 'Più'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers-home_4351cfebe4b61d8aa5efa1d020710005'] = 'Visualizza'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers-home_eae99cd6a931f3553123420b16383812'] = 'Tutte le migliori vendite'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers-home_f7be84d6809317a6eb0ff3823a936800'] = 'Non ci sono migliori vendite in questo momento'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_3cb29f0ccc5fd220a97df89dafe46290'] = 'Migliori vendite'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_eae99cd6a931f3553123420b16383812'] = 'Tutte le migliori vendite'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_f7be84d6809317a6eb0ff3823a936800'] = 'Non ci sono migliori vendite in questo momento'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_6232eaff79c9ccb6c1a66e5a75a212d5'] = 'Blocco migliori vendite'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_95d17a0a1b5ea2de13a3565ed400ebbb'] = 'Aggiungi un blocco che mostra le migliori vendite del negozio'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Conferma'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_c888438d14855d7d96a2724ee9c306bd'] = 'Impostazioni aggiornate'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_f4f70727dc34561dfde1a3c529b6205c'] = 'Impostazioni'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_530c88f8210e022b39128e3f0409bbcf'] = 'Visualizza sempre blocco'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Attivato'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_b9f5c797ebbf55adccdd8539a65a0241'] = 'Disattivato'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_a8a670d89a6d2f3fa59942fc591011ef'] = 'Mostra il blocco anche se nessun prodotto è disponibile.'; +$_MODULE['<{blockbestsellers}prestashop>blockbestsellers_c9cc8cce247e49bae79f15173ce97354'] = 'Salva'; + +?> \ No newline at end of file diff --git a/modules/privatesales_similarproducts/privatesales_similarproducts.php b/modules/privatesales_similarproducts/privatesales_similarproducts.php new file mode 100755 index 00000000..3eaee890 --- /dev/null +++ b/modules/privatesales_similarproducts/privatesales_similarproducts.php @@ -0,0 +1,191 @@ + array('Accessories or similar products', 'Called on displaying similar product in product details'), + ); + + public function __construct() + { + $this->name = 'privatesales_similarproducts'; + $this->tab = 'front_office_features'; + $this->version = '1.0'; + $this->author = 'Antadis'; + $this->need_instance = 0; + + parent::__construct(); + + $this->displayName = $this->l('Produits complémentaires ou similaires'); + $this->description = $this->l('Ajoute un bloc affichant les produits complémentaires (accessoires) ou les meilleures ventes de la famille d\'un produit.'); + } + + /** + * @see ModuleCore::install() + */ + public function install() + { + // Add custom hooks + foreach($this->hooks as $k => $v) { + if(count(Db::getInstance()->ExecuteS(' + SELECT `id_hook` + FROM `'._DB_PREFIX_.'hook` + WHERE `name` = "'.$k.'" + LIMIT 1 + ')) == 0) { + Db::getInstance()->ExecuteS(' + INSERT INTO `'._DB_PREFIX_.'hook` + VALUES (DEFAULT, "'.$k.'", "'.$v[0].'", "'.$v[1].'", 0, 0) + '); + } + } + + if (!parent::install() || + !$this->registerHook('similarProduct')) { + $this->uninstall(); + return false; + } + return true; + } + + public function uninstall() + { + // Remove custom hooks + foreach($this->hooks as $k => $v) { + Db::getInstance()->Execute(' + DELETE FROM `'._DB_PREFIX_.'hook` + WHERE `name` = "'.$k.'" + '); + } + parent::uninstall(); + } + + public function hookSimilarProduct($params) + { + if(_PS_MOBILE_) { + return false; + } + $result = $this->displayAccessories($params); + if ($result=='') { + return $this->displayBestVPSalesSameFamily($params); + } + return $result; + } + + + private function displayAccessories($params) + { + global $smarty; + global $cookie; + + $id_lang = $cookie->id_lang; + + $cache_params = [ + 'prefix_cache' => '1_'.$params['product']->id + ]; + if (!$this->isTemplateCached($cache_params)) { + + $currency = new Currency((int)($params['cookie']->id_currency)); + + // get all accessories of this product + $products = array(); + + $accessories = $params['product']->getAccessories($id_lang); + if($accessories) { + foreach ($accessories AS $accessory) + { + $accessory['price'] = Tools::displayPrice(Product::getPriceStatic((int)($accessory['id_product'])), $currency); + $products[] = $accessory; + } + } + + if (!$products || count($products)==0) { + return ''; + } + + $smarty->assign( + array( + 'is_accessories' => ($accessories !== FALSE && count($accessories)>0), + 'best_sellers' => $products, + ) + ); + } + + return $this->flushTemplateCache($cache_params); + } + + + private function displayBestVPSalesSameFamily($params) + { + global $smarty; + global $cookie; + + $id_lang = $cookie->id_lang; + $cache_params = [ + 'prefix_cache' => '2_'.$params['sale']->id, + ]; + + if (!$this->isTemplateCached($cache_params)) { + $currency = new Currency((int)($params['cookie']->id_currency)); + + // get all best sales of the product family + if (count($products)==0) { + $bestsellers = ProductSale::getBestSalesVpForProductFamily($params['product']->id, (int)($params['cookie']->id_lang), 0, 6, NULL, NULL, 10); + + if($bestsellers) { + foreach ($bestsellers AS $bestseller) { + $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency); + $products[] = $bestseller; + } + } + } + + if (!$products || count($products)==0) { + return ''; + } + + $smarty->assign( + array( + 'is_accessories' => ($accessories !== FALSE && count($accessories)>0), + 'best_sellers' => $products, + ) + ); + } + + return $this->flushTemplateCache($cache_params); + + } + + private function isTemplateCached(&$cache_params) + { + global $smarty; + global $cookie; + + Tools::enableCache(); + $smarty->cache_lifetime = 3600; + + $cache_params['compile_id'] = $cache_params['prefix_cache'].'_'.(int)$cookie->id_lang; + $cache_params['cache_id'] = $cache_params['compile_id'].'_front_similarproducts'; + + return $this->isCached('front_similarproducts.tpl', $cache_id, $compile_id); + } + + private function flushTemplateCache($cache_params) + { + $display = $this->display( + __FILE__, + 'front_similarproducts.tpl' , + $cache_params['cache_id'], + $cache_params['compile_id'] + ); + Tools::restoreCacheSettings(); + $smarty->cache_lifetime = -1; + return $display; + } +} + + diff --git a/override/classes/ProductSale.php b/override/classes/ProductSale.php index f44b7cbf..9a4eb429 100644 --- a/override/classes/ProductSale.php +++ b/override/classes/ProductSale.php @@ -1,9 +1,45 @@ self::_getIdCategoryPrivateSalesOfProduct($id_product), + 'id_lang' => $id_lang, + 'page_number' => $pageNumber, + 'nb_products' => $nbProducts, + 'order_by' => $orderBy, + 'order_way' => $orderWay, + 'filter_price' => $filterPrice + ) + ); + } + public static function getBestSalesVp($id_lang, $pageNumber = 0, $nbProducts = 10, $orderBy=NULL, $orderWay=NULL, $filterPrice=NULL) { - $id_category_vp = self::_getIdCategoryPrivateSales(); + return self::getBestSalesForCategories( + array( + 'categories' => self::_getIdCategoryPrivateSales(), + 'id_lang' => $id_lang, + 'page_number' => $pageNumber, + 'nb_products' => $nbProducts, + 'order_by' => $orderBy, + 'order_way' => $orderWay, + 'filter_price' => $filterPrice + ) + ); + } + + private static function getBestSalesForCategories($params) + { + $id_category_vp = $params['categories']; + $id_lang = $params['id_lang']; + $pageNumber = $params['page_number']; + $nbProducts = $params['nb_products']; + $orderBy = $params['order_by']; + $orderWay = $params['order_way']; + $filterPrice = $params['filter_price']; // $id_category_vp = array_unique($id_category_vp); if ($pageNumber < 0) $pageNumber = 0; @@ -108,4 +144,20 @@ class ProductSale extends ProductSaleCore '; return $sales = Db::getInstance()->ExecuteS($query); } + + private static function _getIdCategoryPrivateSalesOfProduct($id_product) + { + global $site_version_front; + $query = ' + SELECT p.`id_category` + FROM `'._DB_PREFIX_.'privatesale` p + INNER JOIN `'._DB_PREFIX_.'category_product` cp ON ( cp.`id_category` = p.`id_category` ) + LEFT JOIN `'._DB_PREFIX_.'privatesale_site_version` v ON v.`id_sale` = p.`id_sale` + WHERE p.`date_start` <= NOW() + AND p.`date_end` >= NOW() + AND cp.`id_product` = '.pSql($id_product).' + AND v.`version` = "'.pSql($site_version_front).'" + '; + return $sales = Db::getInstance()->ExecuteS($query); + } } diff --git a/override/controllers/ProductController.php b/override/controllers/ProductController.php index 683c6855..19b11fd0 100755 --- a/override/controllers/ProductController.php +++ b/override/controllers/ProductController.php @@ -44,6 +44,7 @@ class ProductController extends ProductControllerCore { self::$smarty->assign(array( 'sale' => $sale, + 'HOOK_SIMILAR_PRODUCT' => Module::hookExec('similarProduct', array('product' => $this->product, 'sale' => $sale)), 'HOOK_PRIVATESALES_PRODUCT' => Module::hookExec('privatesales_product', array('sale' => $sale)), 'is_sale_home' => ($sale? $sale->id_category == $id_category: FALSE), 'is_thumb_vp' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg')), diff --git a/themes/site/css/style.css b/themes/site/css/style.css index e50f077d..7d2f9168 100755 --- a/themes/site/css/style.css +++ b/themes/site/css/style.css @@ -6757,3 +6757,170 @@ table#carrierTable tbody td { font-weight: bold; } +/* ticket 8048 - Product details - Other similar products / best sales for product family */ +/* Slider product footer (blockbestsellers)*/ +#product #privatesales_similarproduct { + position: relative; +} +#product #privatesales_similarproduct h1 { + background-size: 100% 100%; + color: #4F4E9A; + margin-right: 0px; +} +#product #privatesales_similarproduct .slider_sales_product_footer { + padding: 20px 60px; + position: relative; + -moz-box-shadow: 0px 0px 5px 1px #cccccc; + -webkit-box-shadow: 0px 0px 5px 1px #CCC; + -ms-box-shadow:: 0px 0px 5px 1px #cccccc; + -o-box-shadow: 0px 0px 5px 1px #cccccc; + box-shadow: 0px 0px 5px 1px #CCC; + margin-bottom:20px; +} +#product #privatesales_similarproduct .flex-direction-nav { + position: inherit; +} +#product #privatesales_similarproduct .flex-control-nav{ + display: none; +} +#product #privatesales_similarproduct .flex-direction-nav .flex-prev, +#product #privatesales_similarproduct .flex-direction-nav .flex-next { + top: -80px; + border-radius: 50%; + width: 50px; + height: 50px; + content: ''; + background: #fff; + color: transparent; + opacity: 1; + -moz-box-shadow: 0px 0px 5px 1px #cccccc; + -webkit-box-shadow: 0px 0px 5px 1px #CCC; + -ms-box-shadow:: 0px 0px 5px 1px #cccccc; + -o-box-shadow: 0px 0px 5px 1px #cccccc; + box-shadow: 0px 0px 5px 1px #CCC; +} +#product #privatesales_similarproduct .flex-direction-nav .flex-prev{ + background: url("../img/arrow_blue_left.png") no-repeat center center #fff; +} +#product #privatesales_similarproduct .flex-direction-nav .flex-next{ + background: url("../img/arrow_blue_right.png") no-repeat center center #fff; +} +#product #privatesales_similarproduct .flex-direction-nav .flex-prev:before, +#product #privatesales_similarproduct .flex-direction-nav .flex-next:before{ + display: none; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides { + padding: 10px 0; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li{ + margin-right: 10px; + margin-left: 10px; + background: #fff; + padding: 10px; + box-sizing: border-box; + position: relative; + max-height: 134px; + + -moz-box-shadow: 0px 0px 5px 1px #cccccc; + -webkit-box-shadow: 0px 0px 5px 1px #CCC; + -ms-box-shadow:: 0px 0px 5px 1px #cccccc; + -o-box-shadow: 0px 0px 5px 1px #cccccc; + box-shadow: 0px 0px 5px 1px #CCC; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .hover-slide, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .product_added{ + display: none; + top: 0; + left: 0; + width:100%; + height:100%; + background-color: rgba(0,0,0,0.7); + box-sizing: border-box; + text-align: center; + position: absolute; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .product_added{ + z-index: 999; + padding: 45px 20px; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .product_added p{ + color: #fff; + font-family: "georgia"; + font-style: italic; + font-weight: bold; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li:hover div.hover-slide{ + display: block; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .hover-slide a{ + display: inline-block; + width: 40%; + height: 100%; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .hover-slide a.add-to-cart { + background: url("../img/panier2.png") no-repeat center center; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .hover-slide a.see-product { + background: url("../img/loupe.png") no-repeat center center; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li:after{ + content: ''; + display: block; + clear: both; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .img_sellers, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers { + text-align: center; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .img_sellers{ + width: 40%; + float: left; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers { + width: 60%; + padding: 5px 10px; + box-sizing: border-box; + background-color: #E4E4EE; + float: right; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .product_link_sellers, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers p.price, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .old_price, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .percentage, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .amount{ + font-family: "georgia"; + font-style: italic; + font-weight: bold; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .product_link_sellers{ + display: block; + display: -webkit-box; + max-width: 110px; + height: 44px; + margin: 0 auto; + font-size: 12px; + line-height: 15px; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + color: #4F4E9A; + font-weight: 500; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .product_link_sellers:hover{ + text-decoration: none; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers p.price{ + border:0; + color: #FB69AA; + font-size: 16px; + padding-top: 18px; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .old_price { + color: #B0B0B0; + text-decoration: line-through; +} +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .percentage, +#product #privatesales_similarproduct .slider_sales_product_footer .slides li .info_sellers .amount{ + color: #4F4E9A; +} diff --git a/themes/site/product.tpl b/themes/site/product.tpl index aae23a6f..215d8bcf 100755 --- a/themes/site/product.tpl +++ b/themes/site/product.tpl @@ -546,38 +546,6 @@ var oneQuantityAvailableSentence = '{l s='Warning: 1 item in stock!' js=1}'; {/foreach} {/if} - {if isset($accessories) AND $accessories} - -
- {if $accessory.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}{if $priceDisplay != 1}{displayWtPrice p=$accessory.price}{else}{displayWtPrice p=$accessory.price_tax_exc}{/if}{/if} - {l s='View'} - {if ($accessory.allow_oosp || $accessory.quantity > 0) AND $accessory.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} - {l s='Add to cart'} - {else} - {l s='Add to cart'} - {if (isset($accessory.quantity_all_versions) && $accessory.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if} - {/if} -
-