date_start) < strtotime(date('Y-m-d 07:00:00')); $sale['img'] = $this->getSaleImage($this->id, $is_active); $sale['reduction'] = $this->extraFields['reduction'] ? $this->extraFields['reduction'] : '0'; return $sale; } static public function apiGetSales($future = false) { global $cookie; $sales = parent::apiGetSales($future); $ids_sales = array(); foreach ($sales as $sale) { $ids_sales[] = $sale->id; } $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 . ' '); foreach ($reductions as $reduction) { foreach ($sales as $sale) { if ((int)$sale->id === (int)$reduction['id_sale']) { $sale = $sale->populate(array( 'reduction' => $reduction['value'], ), $reduction['id_sale']); break; } } } return $sales; } }