fix when no ids_sales providede
This commit is contained in:
parent
6f11a89660
commit
615d2a9113
@ -35,20 +35,23 @@ class Sale extends BaseSale {
|
||||
* )
|
||||
*/
|
||||
static public function getTagsBySaleIds(array $ids_sales) {
|
||||
$tags = \Db::getInstance()->executeS('
|
||||
SELECT p.`id_sale`, pcf.`id_parent` as `id_tag`
|
||||
FROM ps_privatesale p
|
||||
LEFT JOIN ps_privatesale_category pc ON (pc.`id_sale` = p.`id_sale`)
|
||||
LEFT JOIN ps_category_family_association pcfa ON (pc.`id_category` = pcfa.`id_category`)
|
||||
LEFT JOIN ps_category_family pcf ON (pcfa.`id_category_family` = pcf.`id_category_family`)
|
||||
WHERE p.`id_sale` IN (' . implode(',', $ids_sales) . ')
|
||||
AND pcf.`id_parent` IS NOT NULL
|
||||
GROUP BY p.`id_sale`, pcf.`id_parent`
|
||||
');
|
||||
|
||||
$sales_tags = array();
|
||||
foreach ($tags as $tag) {
|
||||
$sales_tags[(int)$tag['id_sale']][] = (int)$tag['id_tag'];
|
||||
|
||||
if (!empty($ids_sales)) {
|
||||
$tags = \Db::getInstance()->executeS('
|
||||
SELECT p.`id_sale`, pcf.`id_parent` as `id_tag`
|
||||
FROM ps_privatesale p
|
||||
LEFT JOIN ps_privatesale_category pc ON (pc.`id_sale` = p.`id_sale`)
|
||||
LEFT JOIN ps_category_family_association pcfa ON (pc.`id_category` = pcfa.`id_category`)
|
||||
LEFT JOIN ps_category_family pcf ON (pcfa.`id_category_family` = pcf.`id_category_family`)
|
||||
WHERE p.`id_sale` IN (' . implode(',', $ids_sales) . ')
|
||||
AND pcf.`id_parent` IS NOT NULL
|
||||
GROUP BY p.`id_sale`, pcf.`id_parent`
|
||||
');
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$sales_tags[(int)$tag['id_sale']][] = (int)$tag['id_tag'];
|
||||
}
|
||||
}
|
||||
return $sales_tags;
|
||||
}
|
||||
@ -65,15 +68,19 @@ class Sale extends BaseSale {
|
||||
static public function getReductionBySaleIds(array $ids_sales) {
|
||||
global $cookie;
|
||||
|
||||
$reductions = \Db::getInstance()->executeS('
|
||||
SELECT id_sale, value FROM ' . _DB_PREFIX_ . 'privatesale_extrafield_sale
|
||||
WHERE `id_field` = 2
|
||||
AND `id_sale` IN (' . implode(',', $ids_sales) . ')
|
||||
AND `id_lang` = ' . (int)$cookie->id_lang . '
|
||||
');
|
||||
$sales_reduction = array();
|
||||
foreach ($reductions as $reduction) {
|
||||
$sales_reduction[(int)$reduction['id_sale']] = $reduction['value'];
|
||||
if (!empty($id_sales)) {
|
||||
$reductions = \Db::getInstance()->executeS('
|
||||
SELECT id_sale, value FROM ' . _DB_PREFIX_ . 'privatesale_extrafield_sale
|
||||
WHERE `id_field` = 2
|
||||
AND `id_sale` IN (' . implode(',', $ids_sales) . ')
|
||||
AND `id_lang` = ' . (int)$cookie->id_lang . '
|
||||
');
|
||||
$sales_reduction = array();
|
||||
foreach ($reductions as $reduction) {
|
||||
$sales_reduction[(int)$reduction['id_sale']] = $reduction['value'];
|
||||
}
|
||||
|
||||
}
|
||||
return $sales_reduction;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user