[*] FO : Code cleaning, optimizations, new callstack available in the profiling tools
This commit is contained in:
+14
-17
@@ -207,16 +207,15 @@ class CurrencyCore extends ObjectModel
|
||||
*
|
||||
* @return array Currencies
|
||||
*/
|
||||
public static function getCurrencies($object = false, $active = 1)
|
||||
public static function getCurrencies($object = false, $active = true)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.Shop::addSqlAssociation('currency', 'c').'
|
||||
WHERE `deleted` = 0'
|
||||
.($active == 1 ? ' AND c.`active` = 1' : '').'
|
||||
GROUP BY c.id_currency
|
||||
ORDER BY `name` ASC';
|
||||
$tab = Db::getInstance()->executeS($sql);
|
||||
$tab = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.Shop::addSqlAssociation('currency', 'c').'
|
||||
WHERE `deleted` = 0
|
||||
'.($active ? ' AND c.`active` = 1' : '').'
|
||||
ORDER BY `name` ASC');
|
||||
if ($object)
|
||||
foreach ($tab as $key => $currency)
|
||||
$tab[$key] = Currency::getCurrencyInstance($currency['id_currency']);
|
||||
@@ -225,14 +224,12 @@ class CurrencyCore extends ObjectModel
|
||||
|
||||
public static function getCurrenciesByIdShop($id_shop = 0)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency_shop` cs ON (cs.`id_currency` = c.`id_currency`)
|
||||
'.($id_shop != 0 ? ' WHERE cs.`id_shop` = '.(int)$id_shop : '').'
|
||||
GROUP BY c.id_currency
|
||||
ORDER BY `name` ASC';
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency_shop` cs ON (cs.`id_currency` = c.`id_currency`)
|
||||
'.($id_shop ? ' WHERE cs.`id_shop` = '.(int)$id_shop : '').'
|
||||
ORDER BY `name` ASC');
|
||||
}
|
||||
|
||||
|
||||
|
||||
+22
-39
@@ -162,22 +162,14 @@ class ManufacturerCore extends ObjectModel
|
||||
if (!Group::isFeatureActive())
|
||||
$all_group = true;
|
||||
|
||||
$sql = 'SELECT m.*, ml.`description`, ml.`short_description`
|
||||
FROM `'._DB_PREFIX_.'manufacturer` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (
|
||||
m.`id_manufacturer` = ml.`id_manufacturer`
|
||||
AND ml.`id_lang` = '.(int)$id_lang.'
|
||||
)
|
||||
'.Shop::addSqlAssociation('manufacturer', 'm');
|
||||
if ($active)
|
||||
$sql .= '
|
||||
WHERE m.`active` = 1';
|
||||
$sql .= '
|
||||
GROUP BY m.id_manufacturer
|
||||
ORDER BY m.`name` ASC'.
|
||||
($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : '');
|
||||
|
||||
$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT m.*, ml.`description`, ml.`short_description`
|
||||
FROM `'._DB_PREFIX_.'manufacturer` m
|
||||
'.Shop::addSqlAssociation('manufacturer', 'm').'
|
||||
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
|
||||
'.($active ? 'WHERE m.`active` = 1' : '').'
|
||||
ORDER BY m.`name` ASC
|
||||
'.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : ''));
|
||||
if ($manufacturers === false)
|
||||
return false;
|
||||
|
||||
@@ -192,35 +184,26 @@ class ManufacturerCore extends ObjectModel
|
||||
|
||||
foreach ($manufacturers as $key => $manufacturer)
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
|
||||
'SELECT p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`)
|
||||
WHERE m.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].
|
||||
($active ? ' AND product_shop.`active` = 1 ' : '').
|
||||
' AND product_shop.`visibility` NOT IN ("none")'.
|
||||
($all_group ? '' : ' AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)')
|
||||
);
|
||||
|
||||
$manufacturers[$key]['nb_products'] = count($result);
|
||||
$manufacturers[$key]['nb_products'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT COUNT(DISTINCT p.`id_product`)
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].'
|
||||
AND product_shop.`visibility` NOT IN ("none")
|
||||
'.($active ? ' AND product_shop.`active` = 1 ' : '').'
|
||||
'.($all_group ? '' : ' AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)'));
|
||||
}
|
||||
}
|
||||
|
||||
$total_manufacturers = count($manufacturers);
|
||||
$rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
|
||||
|
||||
for ($i = 0; $i < $total_manufacturers; $i++)
|
||||
if ($rewrite_settings)
|
||||
$manufacturers[$i]['link_rewrite'] = Tools::link_rewrite($manufacturers[$i]['name']);
|
||||
else
|
||||
$manufacturers[$i]['link_rewrite'] = 0;
|
||||
|
||||
$manufacturers[$i]['link_rewrite'] = ($rewrite_settings ? Tools::link_rewrite($manufacturers[$i]['name']) : 0);
|
||||
return $manufacturers;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,6 @@ class SupplierCore extends ObjectModel
|
||||
$query->where('s.`active` = 1');
|
||||
$query->orderBy(' s.`name` ASC');
|
||||
$query->limit($n, ($p - 1) * $n);
|
||||
$query->groupBy('s.id_supplier');
|
||||
|
||||
$suppliers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
if ($suppliers === false)
|
||||
@@ -159,10 +158,7 @@ class SupplierCore extends ObjectModel
|
||||
$nb_suppliers = count($suppliers);
|
||||
$rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
|
||||
for ($i = 0; $i < $nb_suppliers; $i++)
|
||||
if ($rewrite_settings)
|
||||
$suppliers[$i]['link_rewrite'] = Tools::link_rewrite($suppliers[$i]['name']);
|
||||
else
|
||||
$suppliers[$i]['link_rewrite'] = 0;
|
||||
$suppliers[$i]['link_rewrite'] = ($rewrite_settings ? Tools::link_rewrite($suppliers[$i]['name']) : 0);
|
||||
return $suppliers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user