Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development

This commit is contained in:
Gregory Roussac
2013-01-03 18:43:14 +01:00
3 changed files with 18 additions and 24 deletions
+1 -2
View File
@@ -423,7 +423,7 @@ class CartCore extends ObjectModel
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`, product_shop.`available_for_order`, product_shop.`price`, p.`weight`, p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`, product_shop.`available_for_order`, product_shop.`price`, p.`weight`,
stock.`quantity` quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, product_shop.`active`, p.`date_add`, stock.`quantity` quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, product_shop.`active`, p.`date_add`,
p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(cp.`id_product`, cp.`id_product_attribute`, cp.`id_address_delivery`) AS unique_id, cp.id_address_delivery, CONCAT(cp.`id_product`, IFNULL(cp.`id_product_attribute`, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.`wholesale_price`, product_shop.advanced_stock_management'); product_shop.`wholesale_price`, product_shop.advanced_stock_management');
// Build FROM // Build FROM
@@ -1507,7 +1507,6 @@ class CartCore extends ObjectModel
// If the cart rule offers a reduction, the amount is prorated (with the products in the package) // If the cart rule offers a reduction, the amount is prorated (with the products in the package)
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0)
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2); $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2);
} }
$order_total_discount = min(Tools::ps_round($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees); $order_total_discount = min(Tools::ps_round($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees);
+4
View File
@@ -28,6 +28,10 @@ global $smarty;
$smarty->debugging = false; $smarty->debugging = false;
$smarty->debugging_ctrl = 'NONE'; $smarty->debugging_ctrl = 'NONE';
/* Smarty should be in compile check mode in the BackOffice */
$smarty->force_compile = false;
$smarty->compile_check = true;
function smartyTranslate($params, &$smarty) function smartyTranslate($params, &$smarty)
{ {
$htmlentities = !isset($params['js']); $htmlentities = !isset($params['js']);
+13 -22
View File
@@ -49,9 +49,9 @@ class BlockViewed extends Module
public function install() public function install()
{ {
if (!parent::install() if (!parent::install()
OR !$this->registerHook('leftColumn') || !$this->registerHook('leftColumn')
OR !$this->registerHook('header') || !$this->registerHook('header')
OR !Configuration::updateValue('PRODUCTS_VIEWED_NBR', 2)) || !Configuration::updateValue('PRODUCTS_VIEWED_NBR', 2))
return false; return false;
return true; return true;
} }
@@ -95,7 +95,7 @@ class BlockViewed extends Module
$id_product = (int)Tools::getValue('id_product'); $id_product = (int)Tools::getValue('id_product');
$productsViewed = (isset($params['cookie']->viewed) && !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array(); $productsViewed = (isset($params['cookie']->viewed) && !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
if (sizeof($productsViewed)) if (count($productsViewed))
{ {
$defaultCover = Language::getIsoById($params['cookie']->id_lang).'-default'; $defaultCover = Language::getIsoById($params['cookie']->id_lang).'-default';
@@ -116,11 +116,11 @@ class BlockViewed extends Module
); );
$productsImagesArray = array(); $productsImagesArray = array();
foreach ($productsImages AS $pi) foreach ($productsImages as $pi)
$productsImagesArray[$pi['id_product']] = $pi; $productsImagesArray[$pi['id_product']] = $pi;
$productsViewedObj = array(); $productsViewedObj = array();
foreach ($productsViewed AS $productViewed) foreach ($productsViewed as $productViewed)
{ {
$obj = (object)'Product'; $obj = (object)'Product';
if (!isset($productsImagesArray[$productViewed]) || (!$obj->active = $productsImagesArray[$productViewed]['active'])) if (!isset($productsImagesArray[$productViewed]) || (!$obj->active = $productsImagesArray[$productViewed]['active']))
@@ -147,29 +147,20 @@ class BlockViewed extends Module
} }
} }
if ($id_product AND !in_array($id_product, $productsViewed)) if ($id_product && !in_array($id_product, $productsViewed))
{ {
// Check if the user to the right of access to this product // Check if the user to the right of access to this product
$result = Db::getInstance()->getRow(' $product = new Product((int)$id_product);
SELECT COUNT(cug.`id_customer`) AS total if ($product->checkAccess((int)$this->context->customer->id))
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'customer_group` cug ON (cug.`id_group` = cg.`id_group`)
WHERE p.`id_product` = '.(int)($id_product).'
'.($this->context->customer->id ? 'AND cug.`id_customer` = '.(int)$this->context->customer->id :
'AND cg.`id_group` = 1')
);
if ($result['total'])
array_unshift($productsViewed, $id_product); array_unshift($productsViewed, $id_product);
} }
$viewed = ''; $viewed = '';
foreach ($productsViewed AS $id_product_viewed) foreach ($productsViewed as $id_product_viewed)
$viewed .= (int)($id_product_viewed).','; $viewed .= (int)($id_product_viewed).',';
$params['cookie']->viewed = rtrim($viewed, ','); $params['cookie']->viewed = rtrim($viewed, ',');
if (!sizeof($productsViewedObj)) if (!count($productsViewedObj))
return ; return;
$this->smarty->assign(array( $this->smarty->assign(array(
'productsViewedObj' => $productsViewedObj, 'productsViewedObj' => $productsViewedObj,
@@ -179,7 +170,7 @@ class BlockViewed extends Module
} }
elseif ($id_product) elseif ($id_product)
$params['cookie']->viewed = (int)($id_product); $params['cookie']->viewed = (int)($id_product);
return ; return;
} }
public function hookLeftColumn($params) public function hookLeftColumn($params)