fix conflict
This commit is contained in:
commit
fce88331a3
@ -86,7 +86,6 @@ class Privatesales_similarproducts extends Module
|
||||
if(_PS_MOBILE_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->initFromHook($params);
|
||||
|
||||
if ($this->has_accessories_state == self::HAS_ACCESSORIES_YES) {
|
||||
@ -129,10 +128,7 @@ class Privatesales_similarproducts extends Module
|
||||
}
|
||||
else {
|
||||
$this->has_accessories_state = self::HAS_ACCESSORIES_NO;
|
||||
$this->family = ProductSale::getSaleFamily(
|
||||
$params['current_cat'],
|
||||
$params['cookie']->id_lang
|
||||
);
|
||||
$this->family = ProductSale::getCategoryFamily($params['category'], $params['sale']->id, $params['cookie']->id_lang);
|
||||
if (!empty($this->family)) {
|
||||
$bestsellers = ProductSale::getFamilyBestSales($this->family['id_category_family'], $params['cookie']->id_lang,3, 10,$params['product']->id);
|
||||
//$this->label = $this->l('Autres produits dans').' '.$this->family['name'];
|
||||
|
@ -111,7 +111,7 @@ class ProductSale extends ProductSaleCore
|
||||
|
||||
|
||||
public static function getSaleFamily(
|
||||
$id_category,
|
||||
$id_sale,
|
||||
$id_lang
|
||||
)
|
||||
{
|
||||
@ -119,19 +119,36 @@ class ProductSale extends ProductSaleCore
|
||||
SELECT DISTINCT a.`id_category_family`, c.`name`
|
||||
FROM `'._DB_PREFIX_.'category_family_association` a
|
||||
JOIN `'._DB_PREFIX_.'category_family_lang` c ON c.`id_category_family` = a.`id_category_family`
|
||||
WHERE a.`id_category` = '.pSql($id_category).'
|
||||
JOIN `'._DB_PREFIX_.'privatesale_category` b ON b.`id_category` = a.`id_category`
|
||||
WHERE b.`id_sale` = '.pSql($id_sale).'
|
||||
AND c.`id_lang` = '.pSql($id_lang);
|
||||
return Db::getInstance()->getRow($query);
|
||||
}
|
||||
|
||||
public static function getCategoryFamily($id_category, $id_sale, $id_lang)
|
||||
{
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT DISTINCT a.`id_category_family`, c.`name`
|
||||
FROM `'._DB_PREFIX_.'category_family_association` a
|
||||
JOIN `'._DB_PREFIX_.'category_family_lang` c ON c.`id_category_family` = a.`id_category_family`
|
||||
WHERE a.`id_category` = '.(int)$id_category.'
|
||||
AND c.`id_lang` = '.(int)$id_lang
|
||||
);
|
||||
if($result) {
|
||||
return $result;
|
||||
} else {
|
||||
$query = '
|
||||
SELECT DISTINCT a.`id_category_family`, c.`name`
|
||||
FROM `'._DB_PREFIX_.'category_family_association` a
|
||||
JOIN `'._DB_PREFIX_.'category_family_lang` c ON c.`id_category_family` = a.`id_category_family`
|
||||
JOIN `'._DB_PREFIX_.'privatesale_category` b ON b.`id_category` = a.`id_category`
|
||||
WHERE b.`id_sale` = '.(int)$id_sale.'
|
||||
AND c.`id_lang` = '.(int)$id_lang;
|
||||
return Db::getInstance()->getRow($query);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFamilyBestSales(
|
||||
$id_category_family,
|
||||
$id_lang,
|
||||
$nb_products_max = 3,
|
||||
$filter_price=0,
|
||||
$exclude_id_product
|
||||
)
|
||||
public static function getFamilyBestSales($id_category_family, $id_lang, $nb_products_max = 3, $filter_price=0, $exclude_id_product)
|
||||
{
|
||||
if ($nb_products_max < 1) {
|
||||
$nb_products_max = 3;
|
||||
@ -155,10 +172,10 @@ class ProductSale extends ProductSaleCore
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
JOIN `'._DB_PREFIX_.'product_sale` ps ON (ps.`id_product` = p.`id_product`)
|
||||
JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
|
||||
JOIN `'._DB_PREFIX_.'category_family_association` cfa ON cfa.id_category = cp.id_category
|
||||
JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_sale` ps ON (ps.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_family_association` cfa ON cfa.id_category = cp.id_category
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
||||
@ -192,7 +209,6 @@ class ProductSale extends ProductSaleCore
|
||||
$filtered_best_sale_products[] = $properties;
|
||||
$nb_products_max--;
|
||||
}
|
||||
|
||||
return $filtered_best_sale_products;
|
||||
}
|
||||
|
||||
|
@ -9,28 +9,26 @@ class ProductController extends ProductControllerCore {
|
||||
$sale = Sale::getSaleFromCategory($id_category);
|
||||
|
||||
/* Finding out the right Category for thumb - 4 levels of category */
|
||||
$product_category = $id_category;
|
||||
$available_cat = $this->product->getCategories();
|
||||
$first_step_cats = Category::getChildren($sale->id_category,$cookie->id_lang);
|
||||
foreach ($first_step_cats as $key => $first_step_cat) {
|
||||
if(in_array($first_step_cat['id_category'], $available_cat)){
|
||||
$first_step_cat = $first_step_cat['id_category'];
|
||||
$current_cat = $$first_step_cat['id_category'];
|
||||
$product_category = $first_step_cat = $first_step_cat['id_category'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$second_step_cats = (isset($first_step_cat))?Category::getChildren((int)$first_step_cat,$cookie->id_lang):array();
|
||||
foreach ($second_step_cats as $key => $second_step_cat) {
|
||||
if(in_array($second_step_cat['id_category'], $available_cat)){
|
||||
$second_step_cat = $second_step_cat['id_category'];
|
||||
$current_cat = $second_step_cat['id_category'];
|
||||
$product_category = $second_step_cat = $second_step_cat['id_category'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$third_step_cats = (isset($second_step_cat))?Category::getChildren((int)$second_step_cat,$cookie->id_lang):array();
|
||||
foreach ($third_step_cats as $key => $third_step_cat) {
|
||||
if(in_array($third_step_cat['id_category'], $available_cat)){
|
||||
$third_step_cat = $third_step_cat['id_category'];
|
||||
$current_cat = $third_step_cat['id_category'];
|
||||
$product_category = $third_step_cat = $third_step_cat['id_category'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -47,8 +45,8 @@ class ProductController extends ProductControllerCore {
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'sale' => $sale,
|
||||
'HOOK_SIMILAR_PRODUCT' => Module::hookExec('similarProduct', array('product' => $this->product, 'current_cat' => $current_cat)),
|
||||
'HOOK_SIMILAR_PRODUCT_TABLABEL' => Module::hookExec('simlarProductTabLabel', array('product' => $this->product, 'current_cat' => $current_cat)),
|
||||
'HOOK_SIMILAR_PRODUCT' => Module::hookExec('similarProduct', array('product' => $this->product, 'sale' => $sale, 'category' => $product_category)),
|
||||
'HOOK_SIMILAR_PRODUCT_TABLABEL' => Module::hookExec('simlarProductTabLabel', array('product' => $this->product, 'sale' => $sale, 'category' => $product_category)),
|
||||
'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')),
|
||||
|
Loading…
Reference in New Issue
Block a user