Merge branch 'ticket-AssociateProducts' into develop
This commit is contained in:
commit
699ceebbf3
@ -130,7 +130,7 @@ class Privatesales_similarproducts extends Module
|
||||
else {
|
||||
$this->has_accessories_state = self::HAS_ACCESSORIES_NO;
|
||||
$this->family = ProductSale::getSaleFamily(
|
||||
$params['sale']->id,
|
||||
$params['current_cat'],
|
||||
$params['cookie']->id_lang
|
||||
);
|
||||
if (!empty($this->family)) {
|
||||
|
@ -26,13 +26,13 @@ class ProductSale extends ProductSaleCore
|
||||
}
|
||||
|
||||
$sale_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT
|
||||
SELECT
|
||||
DISTINCT(p.id_product), p.`out_of_stock`, p.`id_category_default`, p.`ean13`,
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer,
|
||||
i.`id_image`, il.`legend`,
|
||||
ps.`quantity` AS sales, t.`rate`, 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
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
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).')
|
||||
@ -48,17 +48,17 @@ class ProductSale extends ProductSaleCore
|
||||
AND p.id_product = (
|
||||
SELECT ps.id_product
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
INNER JOIN `'._DB_PREFIX_.'category_product` cp ON ( cp.id_product = ps.id_product )
|
||||
INNER JOIN `'._DB_PREFIX_.'category_product` cp ON ( cp.id_product = ps.id_product )
|
||||
WHERE cp.id_category IN ('. implode(',', $categories).')
|
||||
ORDER BY ps.quantity DESC
|
||||
ORDER BY ps.quantity DESC
|
||||
LIMIT 1
|
||||
)
|
||||
');
|
||||
|
||||
|
||||
|
||||
if (!$sale_product)
|
||||
continue;
|
||||
|
||||
|
||||
$data = Product::getProductsProperties($id_lang, $sale_product, false);
|
||||
if (isset($filterPrice) && is_int($filterPrice) && $data[0]['price']<$filterPrice) {
|
||||
continue;
|
||||
@ -68,7 +68,7 @@ class ProductSale extends ProductSaleCore
|
||||
}
|
||||
$final_array = self::bubble_sort($result);
|
||||
$final_array = array_reverse($final_array);
|
||||
|
||||
|
||||
return array_slice($final_array,0,$nbProducts);
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ class ProductSale extends ProductSaleCore
|
||||
while($ok);
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
private static function _getIdCategoryPrivateSales()
|
||||
{
|
||||
global $site_version_front;
|
||||
@ -111,26 +111,25 @@ class ProductSale extends ProductSaleCore
|
||||
|
||||
|
||||
public static function getSaleFamily(
|
||||
$id_sale,
|
||||
$id_category,
|
||||
$id_lang
|
||||
)
|
||||
{
|
||||
$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` = '.pSql($id_sale).'
|
||||
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).'
|
||||
AND c.`id_lang` = '.pSql($id_lang);
|
||||
return Db::getInstance()->getRow($query);
|
||||
}
|
||||
|
||||
|
||||
public static function getFamilyBestSales(
|
||||
$id_category_family,
|
||||
$id_lang,
|
||||
$nb_products_max = 3,
|
||||
$filter_price=0,
|
||||
$id_category_family,
|
||||
$id_lang,
|
||||
$nb_products_max = 3,
|
||||
$filter_price=0,
|
||||
$exclude_id_product
|
||||
)
|
||||
{
|
||||
@ -144,18 +143,18 @@ class ProductSale extends ProductSaleCore
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
DISTINCT(p.`id_product`), p.`out_of_stock`, p.`id_category_default`, p.`ean13`,
|
||||
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
m.`name` AS manufacturer_name,
|
||||
SELECT
|
||||
DISTINCT(p.`id_product`), p.`out_of_stock`, p.`id_category_default`, p.`ean13`,
|
||||
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
m.`name` AS manufacturer_name,
|
||||
p.`id_manufacturer` AS id_manufacturer,
|
||||
i.`id_image`, il.`legend`,
|
||||
ps.`quantity` AS sales,
|
||||
ps.`quantity` AS sales,
|
||||
t.`rate`,
|
||||
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
|
||||
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
|
||||
@ -198,7 +197,7 @@ class ProductSale extends ProductSaleCore
|
||||
}
|
||||
|
||||
/**
|
||||
* display all categories (parents/children) having opened private sales the current version (lang)
|
||||
* display all categories (parents/children) having opened private sales the current version (lang)
|
||||
* and for the given family
|
||||
*/
|
||||
private static function _getPrivateSalesCategoriesOfFamily($id_category_family)
|
||||
@ -215,7 +214,7 @@ class ProductSale extends ProductSaleCore
|
||||
AND `sale`.`date_start` <= NOW()
|
||||
AND `sale`.`date_end` >= NOW()
|
||||
AND `vers`.`version` = "'.pSql($site_version_front).'"
|
||||
';
|
||||
';
|
||||
return Db::getInstance()->ExecuteS($query);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ class ProductController extends ProductControllerCore {
|
||||
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'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -21,6 +22,7 @@ class ProductController extends ProductControllerCore {
|
||||
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'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -28,6 +30,7 @@ class ProductController extends ProductControllerCore {
|
||||
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'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -44,8 +47,8 @@ class ProductController extends ProductControllerCore {
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'sale' => $sale,
|
||||
'HOOK_SIMILAR_PRODUCT' => Module::hookExec('similarProduct', array('product' => $this->product, 'sale' => $sale)),
|
||||
'HOOK_SIMILAR_PRODUCT_TABLABEL' => Module::hookExec('simlarProductTabLabel', array('product' => $this->product, '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_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