Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/css/modules.css admin-dev/themes/default/template/controllers/carts/helpers/view/view.tpl admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl admin-dev/themes/default/template/controllers/products/images.tpl admin-dev/themes/default/template/controllers/products/prices.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl classes/Autoload.php classes/Carrier.php classes/Product.php classes/ProductSale.php classes/Tools.php classes/Validate.php classes/tax/TaxRulesTaxManager.php controllers/admin/AdminPPreferencesController.php controllers/admin/AdminPerformanceController.php install-dev/install_version.php js/admin_carrier_wizard.js modules/blockcategories/blockcategories.php modules/blocklayered/blocklayered.php modules/statsequipment/statsequipment.php modules/statsproduct/statsproduct.php modules/watermark/watermark.php themes/default/address.tpl themes/default/authentication.tpl themes/default/category.tpl themes/default/contact-form.tpl themes/default/css/history.css themes/default/header.tpl themes/default/js/cart-summary.js themes/default/js/product.js themes/default/mobile/order-detail.tpl themes/default/modules/blocksearch/blocksearch.tpl themes/default/modules/productcomments/productcomments.tpl themes/default/order-carrier.tpl themes/default/order-detail.tpl themes/default/order-opc-new-account.tpl themes/default/product.tpl
This commit is contained in:
@@ -97,18 +97,24 @@ class ProductComment extends ObjectModel
|
||||
if ($n != null && $n <= 0)
|
||||
$n = 5;
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pc.`id_product_comment`,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
|
||||
IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
|
||||
WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
|
||||
ORDER BY pc.`date_add` DESC
|
||||
'.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
|
||||
$cache_id = 'ProductComment::getByProduct_'.(int)$id_product.'-'.(int)$p.'-'.(int)$n.'-'.(int)$id_customer.'-'.(bool)$validate;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pc.`id_product_comment`,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
|
||||
IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
|
||||
WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
|
||||
ORDER BY pc.`date_add` DESC
|
||||
'.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,18 +124,24 @@ class ProductComment extends ObjectModel
|
||||
*/
|
||||
public static function getByCustomer($id_product, $id_customer, $get_last = false, $id_guest = false)
|
||||
{
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
|
||||
ORDER BY pc.`date_add` DESC '
|
||||
.($get_last ? 'LIMIT 1' : '')
|
||||
);
|
||||
$cache_id = 'ProductComment::getByCustomer_'.(int)$id_product.'-'.(int)$id_customer.'-'.(bool)$get_last.'-'.(int)$id_guest;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
|
||||
ORDER BY pc.`date_add` DESC '
|
||||
.($get_last ? 'LIMIT 1' : '')
|
||||
);
|
||||
|
||||
if ($get_last)
|
||||
$results = array_shift($results);
|
||||
return $results;
|
||||
if ($get_last && count($results))
|
||||
$results = array_shift($results);
|
||||
|
||||
Cache::store($cache_id, $results);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,12 +214,16 @@ class ProductComment extends ObjectModel
|
||||
if (!Validate::isUnsignedId($id_product))
|
||||
die(Tools::displayError());
|
||||
$validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE');
|
||||
if (($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT COUNT(`id_product_comment`) AS "nbr"
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''))) === false)
|
||||
return false;
|
||||
return (int)($result['nbr']);
|
||||
$cache_id = 'ProductComment::getCommentNumber_'.(int)$id_product.'-'.$validate;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT COUNT(`id_product_comment`) AS "nbr"
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''));
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,26 +159,33 @@ class ProductCommentCriterion extends ObjectModel
|
||||
$table = '_shop';
|
||||
$alias = 'ps';
|
||||
}
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT pcc.`id_product_comment_criterion`, pccl.`name`
|
||||
FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl
|
||||
ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp
|
||||
ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = '.(int)$id_product.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_category` pccc
|
||||
ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.'
|
||||
ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.')
|
||||
WHERE pccl.`id_lang` = '.(int)($id_lang).'
|
||||
AND (
|
||||
pccp.id_product IS NOT NULL
|
||||
OR ps.id_product IS NOT NULL
|
||||
OR pcc.id_product_comment_criterion_type = 1
|
||||
)
|
||||
AND pcc.active = 1
|
||||
GROUP BY pcc.id_product_comment_criterion
|
||||
');
|
||||
|
||||
$cache_id = 'ProductCommentCriterion::getByProduct_'.(int)$id_product.'-'.(int)$id_lang;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT pcc.`id_product_comment_criterion`, pccl.`name`
|
||||
FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl
|
||||
ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp
|
||||
ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = '.(int)$id_product.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_category` pccc
|
||||
ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.'
|
||||
ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.')
|
||||
WHERE pccl.`id_lang` = '.(int)($id_lang).'
|
||||
AND (
|
||||
pccp.id_product IS NOT NULL
|
||||
OR ps.id_product IS NOT NULL
|
||||
OR pcc.id_product_comment_criterion_type = 1
|
||||
)
|
||||
AND pcc.active = 1
|
||||
GROUP BY pcc.id_product_comment_criterion
|
||||
');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -684,11 +684,14 @@ class ProductComments extends Module
|
||||
{
|
||||
require_once(dirname(__FILE__).'/ProductComment.php');
|
||||
require_once(dirname(__FILE__).'/ProductCommentCriterion.php');
|
||||
|
||||
$average = ProductComment::getAverageGrade((int)Tools::getValue('id_product'));
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'),
|
||||
'comments' => ProductComment::getByProduct((int)(Tools::getValue('id_product'))),
|
||||
'criterions' => ProductCommentCriterion::getByProduct((int)(Tools::getValue('id_product')), $this->context->language->id),
|
||||
'averageTotal' => round($average['grade']),
|
||||
'nbComments' => (int)(ProductComment::getCommentNumber((int)(Tools::getValue('id_product'))))
|
||||
));
|
||||
|
||||
|
||||
@@ -93,11 +93,13 @@ var moderation_active = {$moderation_active};
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if isset($product) && $product}
|
||||
<!-- Fancybox -->
|
||||
<div style="display: none;">
|
||||
<div id="new_comment_form">
|
||||
<form id="id_new_comment_form" action="#">
|
||||
<h2 class="title">{l s='Write your review' mod='productcomments'}</h2>
|
||||
{if isset($product) && $product}
|
||||
<div class="product clearfix">
|
||||
<img src="{$link->getImageLink($product->link_rewrite, $productcomment_cover, 'home_default')|escape:'html'}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product->name|escape:html:'UTF-8'}" />
|
||||
<div class="product_desc">
|
||||
@@ -105,7 +107,7 @@ var moderation_active = {$moderation_active};
|
||||
{$product->description_short}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
<div class="new_comment_form_content">
|
||||
<h2>{l s='Write your review' mod='productcomments'}</h2>
|
||||
|
||||
@@ -156,3 +158,4 @@ var moderation_active = {$moderation_active};
|
||||
</div>
|
||||
</div>
|
||||
<!-- End fancybox -->
|
||||
{/if}
|
||||
Reference in New Issue
Block a user