Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
@@ -1 +0,0 @@
|
||||
* text=auto
|
||||
+3
-4
@@ -538,11 +538,10 @@ class TabCore extends ObjectModel
|
||||
foreach($tab->attributes() as $key => $value)
|
||||
if ($key == 'display_type')
|
||||
$display_type = (string)$value;
|
||||
|
||||
|
||||
foreach ($tab->children() as $module)
|
||||
foreach ($module->attributes() as $k => $v)
|
||||
if ($k == 'name')
|
||||
$modules_list[$display_type][] = (string)$v;
|
||||
$modules_list[$display_type][(int)$module['position']] = (string)$module['name'];
|
||||
ksort($modules_list[$display_type]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1534,7 +1534,6 @@ class AdminControllerCore extends Controller
|
||||
|
||||
public function renderModulesList()
|
||||
{
|
||||
|
||||
if ($this->getModulesList($this->filter_modules_list))
|
||||
{
|
||||
$helper = new Helper();
|
||||
@@ -2233,7 +2232,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
$all_modules = Module::getModulesOnDisk(true);
|
||||
$this->modules_list = array();
|
||||
foreach($all_modules as $module)
|
||||
foreach ($all_modules as $module)
|
||||
{
|
||||
$perm = true;
|
||||
if ($module->id)
|
||||
@@ -2249,9 +2248,11 @@ class AdminControllerCore extends Controller
|
||||
if (in_array($module->name, $filter_modules_list) && $perm)
|
||||
{
|
||||
$this->fillModuleData($module, 'select');
|
||||
$this->modules_list[] = $module;
|
||||
$this->modules_list[array_search($module->name, $filter_modules_list)] = $module;
|
||||
}
|
||||
}
|
||||
ksort($this->modules_list);
|
||||
|
||||
if (count($this->modules_list))
|
||||
return true;
|
||||
|
||||
|
||||
@@ -351,7 +351,6 @@ class HelperCore
|
||||
public function renderModulesList($modules_list)
|
||||
{
|
||||
$this->tpl_vars = array('modules_list' => $modules_list);
|
||||
|
||||
$tpl = $this->createTemplate('helpers/modules_list/list.tpl');
|
||||
$tpl->assign($this->tpl_vars);
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ class WebserviceOutputBuilderCore
|
||||
protected $virtualFields = array();
|
||||
protected $statusInt;
|
||||
protected $wsParamOverrides;
|
||||
|
||||
protected static $_cache_ws_parameters = array();
|
||||
|
||||
// Header properties
|
||||
protected $headerParams = array(
|
||||
@@ -359,7 +361,11 @@ class WebserviceOutputBuilderCore
|
||||
$type_of_view = self::VIEW_DETAILS;
|
||||
}
|
||||
|
||||
$ws_params = $objects['empty']->getWebserviceParameters();
|
||||
$class = get_class($objects['empty']);
|
||||
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
|
||||
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $objects['empty']->getWebserviceParameters();
|
||||
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
|
||||
|
||||
foreach ($this->wsParamOverrides AS $p)
|
||||
{
|
||||
$object = $p['object'];
|
||||
@@ -406,7 +412,11 @@ class WebserviceOutputBuilderCore
|
||||
*/
|
||||
public function renderEntityMinimum($object, $depth)
|
||||
{
|
||||
$ws_params = $object->getWebserviceParameters();
|
||||
$class = get_class($object);
|
||||
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
|
||||
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
|
||||
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
|
||||
|
||||
$more_attr['id'] = $object->id;
|
||||
$more_attr['xlink_resource'] = $this->wsUrl.$ws_params['objectsNodeName'].'/'.$object->id;
|
||||
$output = $this->setIndent($depth).$this->objectRender->renderNodeHeader($ws_params['objectNodeName'], $ws_params, $more_attr, false);
|
||||
@@ -446,7 +456,12 @@ class WebserviceOutputBuilderCore
|
||||
public function renderEntity($object, $depth)
|
||||
{
|
||||
$output = '';
|
||||
$ws_params = $object->getWebserviceParameters();
|
||||
|
||||
$class = get_class($object);
|
||||
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
|
||||
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
|
||||
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
|
||||
|
||||
foreach ($this->wsParamOverrides AS $p)
|
||||
{
|
||||
$o = $p['object'];
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>crossselling</name>
|
||||
<displayName><![CDATA[Cross Selling]]></displayName>
|
||||
<version><![CDATA[0.1]]></version>
|
||||
<description><![CDATA[Customers who bought this product also bought:]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<module>
|
||||
<name>crossselling</name>
|
||||
<displayName><![CDATA[Cross Selling]]></displayName>
|
||||
<version><![CDATA[0.7]]></version>
|
||||
<description><![CDATA[Customers who bought this product also bought:]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
</module>
|
||||
@@ -35,7 +35,7 @@ class CrossSelling extends Module
|
||||
{
|
||||
$this->name = 'crossselling';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = 0.1;
|
||||
$this->version = 0.7;
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -54,18 +54,18 @@ class CrossSelling extends Module
|
||||
!$this->registerHook('productFooter') OR
|
||||
!$this->registerHook('header') OR
|
||||
!$this->registerHook('shoppingCart') OR
|
||||
!$this->registerHook('actionOrderStatusPostUpdate') OR
|
||||
!Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', 0) OR
|
||||
!Configuration::updateValue('CROSSSELLING_NBR', 10))
|
||||
return false;
|
||||
$this->_clearCache('crossselling.tpl');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('crossselling.tpl');
|
||||
if (!parent::uninstall() OR
|
||||
!$this->unregisterHook('productFooter') OR
|
||||
!$this->unregisterHook('header') OR
|
||||
!$this->unregisterHook('shoppingCart') OR
|
||||
!Configuration::deleteByName('CROSSSELLING_DISPLAY_PRICE') OR
|
||||
!Configuration::deleteByName('CROSSSELLING_NBR'))
|
||||
return false;
|
||||
@@ -88,6 +88,7 @@ class CrossSelling extends Module
|
||||
{
|
||||
Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int)Tools::getValue('displayPrice'));
|
||||
Configuration::updateValue('CROSSSELLING_NBR', (int)Tools::getValue('productNbr'));
|
||||
$this->_clearCache('crossselling.tpl');
|
||||
$this->_html .= $this->displayConfirmation($this->l('Settings updated successfully'));
|
||||
}
|
||||
}
|
||||
@@ -126,66 +127,69 @@ class CrossSelling extends Module
|
||||
if (!$params['products'])
|
||||
return;
|
||||
|
||||
$qOrders = '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 (';
|
||||
$nProducts = count($params['products']);
|
||||
$i = 1;
|
||||
$pIds = array();
|
||||
foreach ($params['products'] as $product)
|
||||
$cache_id = 'crossselling|shoppingcart|'.(int)$params['products'];
|
||||
if (!$this->isCached('crossselling.tpl', $this->getCacheId($cache_id)))
|
||||
{
|
||||
$qOrders .= 'od.product_id = '.(int)$product['id_product'];
|
||||
if ($i < $nProducts)
|
||||
$qOrders .= ' OR ';
|
||||
++$i;
|
||||
$pIds[] = (int)$product['id_product'];
|
||||
}
|
||||
$qOrders .= ')';
|
||||
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($qOrders);
|
||||
|
||||
if (sizeof($orders))
|
||||
{
|
||||
|
||||
$list = '';
|
||||
foreach ($orders AS $order)
|
||||
$list .= (int)$order['id_order'].',';
|
||||
$list = rtrim($list, ',');
|
||||
|
||||
$list_product_ids = join(',', $pIds);
|
||||
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13
|
||||
FROM '._DB_PREFIX_.'order_detail od
|
||||
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
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)$this->context->language->id.'
|
||||
AND cl.id_lang = '.(int)$this->context->language->id.'
|
||||
AND od.product_id NOT IN ('.$list_product_ids.')
|
||||
AND i.cover = 1
|
||||
AND product_shop.active = 1
|
||||
ORDER BY RAND()
|
||||
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').'
|
||||
');
|
||||
|
||||
$taxCalc = Product::getTaxCalculationMethod();
|
||||
foreach ($orderProducts AS &$orderProduct)
|
||||
$qOrders = '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 (';
|
||||
$nProducts = count($params['products']);
|
||||
$i = 1;
|
||||
$pIds = array();
|
||||
foreach ($params['products'] as $product)
|
||||
{
|
||||
$orderProduct['image'] = $this->context->link->getImageLink($orderProduct['link_rewrite'], (int)$orderProduct['product_id'].'-'.(int)$orderProduct['id_image'], ImageType::getFormatedName('medium'));
|
||||
$orderProduct['link'] = $this->context->link->getProductLink((int)$orderProduct['product_id'], $orderProduct['link_rewrite'], $orderProduct['category'], $orderProduct['ean13']);
|
||||
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND ($taxCalc == 0 OR $taxCalc == 2))
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], true, NULL);
|
||||
elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND $taxCalc == 1)
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], false, NULL);
|
||||
$qOrders .= 'od.product_id = '.(int)$product['id_product'];
|
||||
if ($i < $nProducts)
|
||||
$qOrders .= ' OR ';
|
||||
++$i;
|
||||
$pIds[] = (int)$product['id_product'];
|
||||
}
|
||||
$qOrders .= ')';
|
||||
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($qOrders);
|
||||
|
||||
$this->smarty->assign(array('order' => (count($pIds) > 1 ? true : false), 'orderProducts' => $orderProducts, 'middlePosition_crossselling' => round(sizeof($orderProducts) / 2, 0),
|
||||
'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')));
|
||||
if (sizeof($orders))
|
||||
{
|
||||
$list = '';
|
||||
foreach ($orders AS $order)
|
||||
$list .= (int)$order['id_order'].',';
|
||||
$list = rtrim($list, ',');
|
||||
|
||||
$list_product_ids = join(',', $pIds);
|
||||
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13
|
||||
FROM '._DB_PREFIX_.'order_detail od
|
||||
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
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)$this->context->language->id.'
|
||||
AND cl.id_lang = '.(int)$this->context->language->id.'
|
||||
AND od.product_id NOT IN ('.$list_product_ids.')
|
||||
AND i.cover = 1
|
||||
AND product_shop.active = 1
|
||||
ORDER BY RAND()
|
||||
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').'
|
||||
');
|
||||
|
||||
$taxCalc = Product::getTaxCalculationMethod();
|
||||
foreach ($orderProducts AS &$orderProduct)
|
||||
{
|
||||
$orderProduct['image'] = $this->context->link->getImageLink($orderProduct['link_rewrite'], (int)$orderProduct['product_id'].'-'.(int)$orderProduct['id_image'], ImageType::getFormatedName('medium'));
|
||||
$orderProduct['link'] = $this->context->link->getProductLink((int)$orderProduct['product_id'], $orderProduct['link_rewrite'], $orderProduct['category'], $orderProduct['ean13']);
|
||||
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND ($taxCalc == 0 OR $taxCalc == 2))
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], true, NULL);
|
||||
elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND $taxCalc == 1)
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], false, NULL);
|
||||
}
|
||||
|
||||
$this->smarty->assign(array('order' => (count($pIds) > 1 ? true : false), 'orderProducts' => $orderProducts, 'middlePosition_crossselling' => round(sizeof($orderProducts) / 2, 0),
|
||||
'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')));
|
||||
}
|
||||
}
|
||||
return $this->display(__FILE__, 'crossselling.tpl');
|
||||
return $this->display(__FILE__, 'crossselling.tpl', $this->getCacheId($cache_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,52 +197,60 @@ class CrossSelling extends Module
|
||||
*/
|
||||
public function hookProductFooter($params)
|
||||
{
|
||||
|
||||
$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)$params['product']->id);
|
||||
|
||||
if (sizeof($orders))
|
||||
$cache_id = 'crossselling|productfooter|'.(int)$params['product']->id;
|
||||
if (!$this->isCached('crossselling.tpl', $this->getCacheId($cache_id)))
|
||||
{
|
||||
$list = '';
|
||||
foreach ($orders AS $order)
|
||||
$list .= (int)$order['id_order'].',';
|
||||
$list = rtrim($list, ',');
|
||||
$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)$params['product']->id);
|
||||
|
||||
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13
|
||||
FROM '._DB_PREFIX_.'order_detail od
|
||||
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
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)$this->context->language->id.'
|
||||
AND cl.id_lang = '.(int)$this->context->language->id.'
|
||||
AND od.product_id != '.(int)$params['product']->id.'
|
||||
AND i.cover = 1
|
||||
AND product_shop.active = 1
|
||||
ORDER BY RAND()
|
||||
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').'
|
||||
');
|
||||
|
||||
$taxCalc = Product::getTaxCalculationMethod();
|
||||
foreach ($orderProducts AS &$orderProduct)
|
||||
if (sizeof($orders))
|
||||
{
|
||||
$orderProduct['image'] = $this->context->link->getImageLink($orderProduct['link_rewrite'], (int)$orderProduct['product_id'].'-'.(int)$orderProduct['id_image'], ImageType::getFormatedName('medium'));
|
||||
$orderProduct['link'] = $this->context->link->getProductLink((int)$orderProduct['product_id'], $orderProduct['link_rewrite'], $orderProduct['category'], $orderProduct['ean13']);
|
||||
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND ($taxCalc == 0 OR $taxCalc == 2))
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], true, NULL);
|
||||
elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND $taxCalc == 1)
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], false, NULL);
|
||||
}
|
||||
$list = '';
|
||||
foreach ($orders AS $order)
|
||||
$list .= (int)$order['id_order'].',';
|
||||
$list = rtrim($list, ',');
|
||||
|
||||
$this->smarty->assign(array('order' => false, 'orderProducts' => $orderProducts, 'middlePosition_crossselling' => round(sizeof($orderProducts) / 2, 0),
|
||||
'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')));
|
||||
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13
|
||||
FROM '._DB_PREFIX_.'order_detail od
|
||||
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
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)$this->context->language->id.'
|
||||
AND cl.id_lang = '.(int)$this->context->language->id.'
|
||||
AND od.product_id != '.(int)$params['product']->id.'
|
||||
AND i.cover = 1
|
||||
AND product_shop.active = 1
|
||||
ORDER BY RAND()
|
||||
LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').'
|
||||
');
|
||||
|
||||
$taxCalc = Product::getTaxCalculationMethod();
|
||||
foreach ($orderProducts AS &$orderProduct)
|
||||
{
|
||||
$orderProduct['image'] = $this->context->link->getImageLink($orderProduct['link_rewrite'], (int)$orderProduct['product_id'].'-'.(int)$orderProduct['id_image'], ImageType::getFormatedName('medium'));
|
||||
$orderProduct['link'] = $this->context->link->getProductLink((int)$orderProduct['product_id'], $orderProduct['link_rewrite'], $orderProduct['category'], $orderProduct['ean13']);
|
||||
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND ($taxCalc == 0 OR $taxCalc == 2))
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], true, NULL);
|
||||
elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') AND $taxCalc == 1)
|
||||
$orderProduct['displayed_price'] = Product::getPriceStatic((int)$orderProduct['product_id'], false, NULL);
|
||||
}
|
||||
|
||||
$this->smarty->assign(array('order' => false, 'orderProducts' => $orderProducts, 'middlePosition_crossselling' => round(sizeof($orderProducts) / 2, 0),
|
||||
'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')));
|
||||
}
|
||||
}
|
||||
return $this->display(__FILE__, 'crossselling.tpl');
|
||||
return $this->display(__FILE__, 'crossselling.tpl', $this->getCacheId($cache_id));
|
||||
}
|
||||
|
||||
public function hookActionOrderStatusPostUpdate($params)
|
||||
{
|
||||
$this->_clearCache('crossselling.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_0_7($object)
|
||||
{
|
||||
return $object->registerHook('actionOrderStatusPostUpdate');
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>productscategory</name>
|
||||
<displayName><![CDATA[Products Category]]></displayName>
|
||||
<version><![CDATA[1.3]]></version>
|
||||
<description><![CDATA[Display products of the same category on the product page.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<module>
|
||||
<name>productscategory</name>
|
||||
<displayName><![CDATA[Products Category]]></displayName>
|
||||
<version><![CDATA[1.4]]></version>
|
||||
<description><![CDATA[Display products of the same category on the product page.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
</module>
|
||||
@@ -34,7 +34,7 @@ class productsCategory extends Module
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'productscategory';
|
||||
$this->version = '1.3';
|
||||
$this->version = '1.4';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->need_instance = 0;
|
||||
@@ -50,16 +50,22 @@ class productsCategory extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() OR !$this->registerHook('productfooter') OR !$this->registerHook('header') OR !Configuration::updateValue('PRODUCTSCATEGORY_DISPLAY_PRICE', 0))
|
||||
return false;
|
||||
return true;
|
||||
Configuration::updateValue('PRODUCTSCATEGORY_DISPLAY_PRICE', 0);
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
return (parent::install()
|
||||
&& $this->registerHook('productfooter')
|
||||
&& $this->registerHook('header')
|
||||
&& $this->registerHook('addproduct')
|
||||
&& $this->registerHook('updateproduct')
|
||||
&& $this->registerHook('deleteproduct')
|
||||
);
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
if (!parent::uninstall() OR !Configuration::deleteByName('PRODUCTSCATEGORY_DISPLAY_PRICE'))
|
||||
return false;
|
||||
return true;
|
||||
Configuration::deleteByName('PRODUCTSCATEGORY_DISPLAY_PRICE');
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
@@ -70,6 +76,7 @@ class productsCategory extends Module
|
||||
elseif (Tools::isSubmit('submitCross'))
|
||||
{
|
||||
Configuration::updateValue('PRODUCTSCATEGORY_DISPLAY_PRICE', Tools::getValue('displayPrice'));
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
$this->_html .= $this->displayConfirmation($this->l('Settings updated successfully'));
|
||||
}
|
||||
$this->_html .= '
|
||||
@@ -100,75 +107,79 @@ class productsCategory extends Module
|
||||
|
||||
public function hookProductFooter($params)
|
||||
{
|
||||
$idProduct = (int)(Tools::getValue('id_product'));
|
||||
$product = new Product((int)($idProduct));
|
||||
|
||||
/* If the visitor has came to this product by a category, use this one */
|
||||
if (isset($params['category']->id_category))
|
||||
$category = $params['category'];
|
||||
/* Else, use the default product category */
|
||||
else
|
||||
{
|
||||
if (isset($product->id_category_default) AND $product->id_category_default > 1)
|
||||
$category = New Category((int)($product->id_category_default));
|
||||
}
|
||||
$id_product = (int)$params['product']->id;
|
||||
$product = $params['product'];
|
||||
|
||||
if (!Validate::isLoadedObject($category) OR !$category->active)
|
||||
return;
|
||||
$cache_id = 'productscategory|'.$id_product.'|'.(isset($params['category']->id_category) ? (int)$params['category']->id_category : $product->id_category_default);
|
||||
|
||||
// Get infos
|
||||
$categoryProducts = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */
|
||||
$sizeOfCategoryProducts = (int)sizeof($categoryProducts);
|
||||
$middlePosition = 0;
|
||||
|
||||
// Remove current product from the list
|
||||
if (is_array($categoryProducts) AND sizeof($categoryProducts))
|
||||
if (!$this->isCached('productscategory.tpl', $this->getCacheId($cache_id)))
|
||||
{
|
||||
foreach ($categoryProducts AS $key => $categoryProduct)
|
||||
if ($categoryProduct['id_product'] == $idProduct)
|
||||
{
|
||||
unset($categoryProducts[$key]);
|
||||
break;
|
||||
}
|
||||
/* If the visitor has came to this product by a category, use this one */
|
||||
if (isset($params['category']->id_category))
|
||||
$category = $params['category'];
|
||||
/* Else, use the default product category */
|
||||
else
|
||||
{
|
||||
if (isset($product->id_category_default) AND $product->id_category_default > 1)
|
||||
$category = new Category((int)$product->id_category_default);
|
||||
}
|
||||
|
||||
if (!Validate::isLoadedObject($category) OR !$category->active)
|
||||
return;
|
||||
|
||||
$taxes = Product::getTaxCalculationMethod();
|
||||
if (Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE'))
|
||||
// Get infos
|
||||
$categoryProducts = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */
|
||||
$sizeOfCategoryProducts = (int)sizeof($categoryProducts);
|
||||
$middlePosition = 0;
|
||||
|
||||
// Remove current product from the list
|
||||
if (is_array($categoryProducts) AND sizeof($categoryProducts))
|
||||
{
|
||||
foreach ($categoryProducts AS $key => $categoryProduct)
|
||||
if ($categoryProduct['id_product'] != $idProduct)
|
||||
if ($categoryProduct['id_product'] == $id_product)
|
||||
{
|
||||
if ($taxes == 0 OR $taxes == 2)
|
||||
$categoryProducts[$key]['displayed_price'] = Product::getPriceStatic((int)$categoryProduct['id_product'], true, NULL, 2);
|
||||
elseif ($taxes == 1)
|
||||
$categoryProducts[$key]['displayed_price'] = Product::getPriceStatic((int)$categoryProduct['id_product'], false, NULL, 2);
|
||||
unset($categoryProducts[$key]);
|
||||
break;
|
||||
}
|
||||
|
||||
// Get positions
|
||||
$middlePosition = round($sizeOfCategoryProducts / 2, 0);
|
||||
$productPosition = $this->getCurrentProduct($categoryProducts, (int)$idProduct);
|
||||
|
||||
// Flip middle product with current product
|
||||
if ($productPosition)
|
||||
{
|
||||
$tmp = $categoryProducts[$middlePosition-1];
|
||||
$categoryProducts[$middlePosition-1] = $categoryProducts[$productPosition];
|
||||
$categoryProducts[$productPosition] = $tmp;
|
||||
}
|
||||
|
||||
// If products tab higher than 30, slice it
|
||||
if ($sizeOfCategoryProducts > 30)
|
||||
{
|
||||
$categoryProducts = array_slice($categoryProducts, $middlePosition - 15, 30, true);
|
||||
$middlePosition = 15;
|
||||
}
|
||||
}
|
||||
|
||||
// Display tpl
|
||||
$this->smarty->assign(array(
|
||||
'categoryProducts' => $categoryProducts,
|
||||
'middlePosition' => (int)$middlePosition,
|
||||
'ProdDisplayPrice' => Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE')));
|
||||
|
||||
return $this->display(__FILE__, 'productscategory.tpl');
|
||||
$taxes = Product::getTaxCalculationMethod();
|
||||
if (Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE'))
|
||||
foreach ($categoryProducts AS $key => $categoryProduct)
|
||||
if ($categoryProduct['id_product'] != $id_product)
|
||||
{
|
||||
if ($taxes == 0 OR $taxes == 2)
|
||||
$categoryProducts[$key]['displayed_price'] = Product::getPriceStatic((int)$categoryProduct['id_product'], true, NULL, 2);
|
||||
elseif ($taxes == 1)
|
||||
$categoryProducts[$key]['displayed_price'] = Product::getPriceStatic((int)$categoryProduct['id_product'], false, NULL, 2);
|
||||
}
|
||||
|
||||
// Get positions
|
||||
$middlePosition = round($sizeOfCategoryProducts / 2, 0);
|
||||
$productPosition = $this->getCurrentProduct($categoryProducts, (int)$id_product);
|
||||
|
||||
// Flip middle product with current product
|
||||
if ($productPosition)
|
||||
{
|
||||
$tmp = $categoryProducts[$middlePosition-1];
|
||||
$categoryProducts[$middlePosition-1] = $categoryProducts[$productPosition];
|
||||
$categoryProducts[$productPosition] = $tmp;
|
||||
}
|
||||
|
||||
// If products tab higher than 30, slice it
|
||||
if ($sizeOfCategoryProducts > 30)
|
||||
{
|
||||
$categoryProducts = array_slice($categoryProducts, $middlePosition - 15, 30, true);
|
||||
$middlePosition = 15;
|
||||
}
|
||||
}
|
||||
|
||||
// Display tpl
|
||||
$this->smarty->assign(array(
|
||||
'categoryProducts' => $categoryProducts,
|
||||
'middlePosition' => (int)$middlePosition,
|
||||
'ProdDisplayPrice' => Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE')));
|
||||
}
|
||||
return $this->display(__FILE__, 'productscategory.tpl', $this->getCacheId($cache_id));
|
||||
}
|
||||
|
||||
public function hookHeader($params)
|
||||
@@ -177,4 +188,19 @@ class productsCategory extends Module
|
||||
$this->context->controller->addJS($this->_path.'productscategory.js');
|
||||
$this->context->controller->addJqueryPlugin('serialScroll');
|
||||
}
|
||||
|
||||
public function hookAddProduct($params)
|
||||
{
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
}
|
||||
|
||||
public function hookUpdateProduct($params)
|
||||
{
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
}
|
||||
|
||||
public function hookDeleteProduct($params)
|
||||
{
|
||||
$this->_clearCache('productscategory.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_4($object)
|
||||
{
|
||||
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct'));
|
||||
}
|
||||
Reference in New Issue
Block a user