// Replace shop->addSqlAssociation() by static call
This commit is contained in:
@@ -91,7 +91,7 @@ class CMSCore extends ObjectModel
|
||||
SELECT c.id_cms, cl.link_rewrite, cl.meta_title
|
||||
FROM '._DB_PREFIX_.'cms c
|
||||
LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = '.(int)$id_lang.')
|
||||
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
|
||||
'.Shop::addSqlAssociation('cms', 'c').'
|
||||
WHERE 1
|
||||
'.(($selection !== null) ? ' AND c.id_cms IN ('.implode(',', array_map('intval', $selection)).')' : '').
|
||||
($active ? ' AND c.`active` = 1 ' : '').
|
||||
@@ -117,7 +117,7 @@ class CMSCore extends ObjectModel
|
||||
SELECT c.id_cms, l.meta_title
|
||||
FROM '._DB_PREFIX_.'cms c
|
||||
JOIN '._DB_PREFIX_.'cms_lang l ON (c.id_cms = l.id_cms)
|
||||
'.Context::getContext()->shop->addSqlAssociation('cms', 'c').'
|
||||
'.Shop::addSqlAssociation('cms', 'c').'
|
||||
'.(($id_block) ? 'JOIN '._DB_PREFIX_.'block_cms b ON (c.id_cms = b.id_cms)' : '').'
|
||||
WHERE l.id_lang = '.(int)$id_lang.(($id_block) ? ' AND b.id_block = '.(int)$id_block : '').($active ? ' AND c.`active` = 1 ' : '').'
|
||||
GROUP BY c.id_cms
|
||||
|
||||
@@ -159,12 +159,10 @@ class CMSCategoryCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null, Shop $shop = null)
|
||||
public static function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null)
|
||||
{
|
||||
if (!$link)
|
||||
$link = Context::getContext()->link;
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
if (is_null($id_lang))
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
@@ -185,7 +183,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms` c
|
||||
'.$shop->addSqlAssociation('cms', 'c', false).'
|
||||
'.Shop::addSqlAssociation('cms', 'c', false).'
|
||||
JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms`
|
||||
WHERE `id_cms_category` = '.(int)$current.'
|
||||
AND cl.`id_lang` = '.(int)$id_lang.($active ? ' AND c.`active` = 1' : '').'
|
||||
|
||||
@@ -615,7 +615,7 @@ class CategoryCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(cp.`id_product`) AS total
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
||||
WHERE cp.`id_category` = '.(int)$this->id.
|
||||
($active ? ' AND p.`active` = 1' : '').
|
||||
@@ -635,7 +635,7 @@ class CategoryCore extends ObjectModel
|
||||
ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
'.Product::sqlStock('p', 'pa', false, $context->shop).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (p.`id_category_default` = cl.`id_category`
|
||||
@@ -737,7 +737,7 @@ class CategoryCore extends ObjectModel
|
||||
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
'.Context::getContext()->shop->addSqlAssociation('category', 'c').'
|
||||
'.Shop::addSqlAssociation('category', 'c').'
|
||||
WHERE `id_lang` = '.(int)$id_lang.'
|
||||
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||
AND c.`id_parent` = '.(int)$id_parent.'
|
||||
|
||||
@@ -64,14 +64,11 @@ class ContactCore extends ObjectModel
|
||||
* @param Context
|
||||
* @return array Contacts
|
||||
*/
|
||||
public static function getContacts($id_lang, Shop $shop = null)
|
||||
public static function getContacts($id_lang)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'contact` c
|
||||
'.$shop->addSqlAssociation('contact', 'c', false).'
|
||||
'.Shop::addSqlAssociation('contact', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`)
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
ORDER BY `name` ASC';
|
||||
|
||||
@@ -114,14 +114,11 @@ class CountryCore extends ObjectModel
|
||||
* @param boolean $active return only active coutries
|
||||
* @return array Countries and corresponding zones
|
||||
*/
|
||||
public static function getCountries($id_lang, $active = false, $contain_states = null, Shop $shop = null)
|
||||
public static function getCountries($id_lang, $active = false, $contain_states = null)
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT s.*
|
||||
FROM `'._DB_PREFIX_.'state` s
|
||||
@@ -129,7 +126,7 @@ class CountryCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$shop->addSqlAssociation('country', 'c', false).'
|
||||
'.Shop::addSqlAssociation('country', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
|
||||
WHERE 1'
|
||||
@@ -275,17 +272,14 @@ class CountryCore extends ObjectModel
|
||||
return Context::getContext()->country->id;
|
||||
}
|
||||
|
||||
public static function getCountriesByZoneId($id_zone, $id_lang, Shop $shop = null)
|
||||
public static function getCountriesByZoneId($id_zone, $id_lang)
|
||||
{
|
||||
if (empty($id_zone) || empty($id_lang))
|
||||
die(Tools::displayError());
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = ' SELECT DISTINCT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$shop->addSqlAssociation('country', 'c', false).'
|
||||
'.Shop::addSqlAssociation('country', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.')
|
||||
|
||||
@@ -195,14 +195,11 @@ class CurrencyCore extends ObjectModel
|
||||
*
|
||||
* @return array Currencies
|
||||
*/
|
||||
public static function getCurrencies($object = false, $active = 1, Shop $shop = null)
|
||||
public static function getCurrencies($object = false, $active = 1)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.$shop->addSqlAssociation('currency', 'c').'
|
||||
'.Shop::addSqlAssociation('currency', 'c').'
|
||||
WHERE `deleted` = 0'
|
||||
.($active == 1 ? ' AND c.`active` = 1' : '').'
|
||||
GROUP BY c.id_currency
|
||||
|
||||
@@ -709,7 +709,7 @@ class LanguageCore extends ObjectModel
|
||||
if (!self::$countActiveLanguages)
|
||||
self::$countActiveLanguages = Db::getInstance()->getValue('
|
||||
SELECT COUNT(*) FROM `'._DB_PREFIX_.'lang` l
|
||||
'.Context::getContext()->shop->addSqlAssociation('lang', 'l').'
|
||||
'.Shop::addSqlAssociation('lang', 'l').'
|
||||
WHERE l.`active` = 1
|
||||
');
|
||||
return self::$countActiveLanguages;
|
||||
|
||||
@@ -296,7 +296,7 @@ class ManufacturerCore extends ObjectModel
|
||||
$sql = '
|
||||
SELECT p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.id_manufacturer = '.(int)$id_manufacturer
|
||||
.($active ? ' AND p.`active` = 1' : '').'
|
||||
AND p.`id_product` IN (
|
||||
@@ -327,7 +327,7 @@ class ManufacturerCore extends ObjectModel
|
||||
) > 0 AS new,
|
||||
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
|
||||
@@ -934,7 +934,7 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
$sql = 'SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, s.`name` AS supplier_name
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_tax_rules_group_shop` ptrgs ON (p.`id_product` = ptrgs.`id_product`
|
||||
AND ptrgs.id_shop='.(int)$context->shop->id.')
|
||||
@@ -963,7 +963,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.`id_product`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
ORDER BY pl.`name`';
|
||||
@@ -1791,7 +1791,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(p.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE `active` = 1
|
||||
AND DATEDIFF(
|
||||
p.`date_add`,
|
||||
@@ -1824,7 +1824,7 @@ class ProductCore extends ObjectModel
|
||||
);
|
||||
|
||||
$sql->from('product', 'p');
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->join(Shop::addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
@@ -1924,7 +1924,7 @@ class ProductCore extends ObjectModel
|
||||
// Please keep 2 distinct queries because RAND() is an awful way to achieve this result
|
||||
$sql = 'SELECT p.id_product
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`active` = 1
|
||||
'.(($ids_product) ? 'AND p.`id_product` IN ('.implode(', ', $ids_product).')' : '').'
|
||||
AND p.`id_product` IN (
|
||||
@@ -1998,7 +1998,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT p.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`active` = 1
|
||||
AND p.`show_price` = 1
|
||||
'.((!$beginning && !$ending) ? 'AND p.`id_product` IN('.((is_array($ids_product) && count($ids_product)) ? implode(', ', array_map('intval', $ids_product)) : 0).')' : '').'
|
||||
@@ -2027,7 +2027,7 @@ class ProductCore extends ObjectModel
|
||||
)
|
||||
) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
'.Product::sqlStock('p', 0, false, $context->shop).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
@@ -2168,7 +2168,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT i.`cover`, i.`id_image`, il.`legend`, i.`position`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.$context->shop->addSqlAssociation('image', 'i').'
|
||||
'.Shop::addSqlAssociation('image', 'i').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$this->id.'
|
||||
ORDER BY `position`';
|
||||
@@ -2187,7 +2187,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT i.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.$context->shop->addSqlAssociation('image', 'i').'
|
||||
'.Shop::addSqlAssociation('image', 'i').'
|
||||
WHERE i.`id_product` = '.(int)$id_product.'
|
||||
AND i.`cover` = 1';
|
||||
return Db::getInstance()->getRow($sql);
|
||||
@@ -2892,7 +2892,7 @@ class ProductCore extends ObjectModel
|
||||
$sql = 'SELECT p.`id_product`, p.`reference`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'accessory`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product`= `id_product_2`)
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
@@ -2925,7 +2925,7 @@ class ProductCore extends ObjectModel
|
||||
) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'accessory`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = `id_product_2`
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
@@ -3093,7 +3093,7 @@ class ProductCore extends ObjectModel
|
||||
$sql->select('p.`id_product`, pl.`name`, p.`active`, p.`reference`, m.`name` AS manufacturer_name, stock.`quantity`, p.advanced_stock_management');
|
||||
$sql->from('category_product', 'cp');
|
||||
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->join(Shop::addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
|
||||
@@ -44,15 +44,12 @@ class ProductSaleCore
|
||||
** Get number of actives products sold
|
||||
** @return int number of actives products listed in product_sales
|
||||
*/
|
||||
public static function getNbSales(Context $context = null)
|
||||
public static function getNbSales()
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT COUNT(ps.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ps.`id_product`
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
WHERE p.`active` = 1';
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
}
|
||||
@@ -65,11 +62,8 @@ class ProductSaleCore
|
||||
** @param integer $nb_products Number of products to return (optional)
|
||||
** @return array from Product::getProductProperties
|
||||
*/
|
||||
public static function getBestSales($id_lang, $page_number = 0, $nb_products = 10, $order_by = null, $order_way = null, Context $context = null)
|
||||
public static function getBestSales($id_lang, $page_number = 0, $nb_products = 10, $order_by = null, $order_way = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
if ($page_number < 0) $page_number = 0;
|
||||
if ($nb_products < 1) $nb_products = 10;
|
||||
if (empty($order_by) || $order_by == 'position') $order_by = 'sales';
|
||||
@@ -89,7 +83,7 @@ class ProductSaleCore
|
||||
INTERVAL '.$interval.' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
@@ -144,7 +138,7 @@ class ProductSaleCore
|
||||
ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
|
||||
@@ -213,7 +213,7 @@ class SceneCore extends ObjectModel
|
||||
$sql = 'SELECT s.*
|
||||
FROM `'._DB_PREFIX_.'scene_category` sc
|
||||
LEFT JOIN `'._DB_PREFIX_.'scene` s ON (sc.id_scene = s.id_scene)
|
||||
'.$context->shop->addSqlAssociation('scene', 's').'
|
||||
'.Shop::addSqlAssociation('scene', 's').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'scene_lang` sl ON (sl.id_scene = s.id_scene)
|
||||
WHERE sc.id_category = '.(int)$id_category.'
|
||||
AND sl.id_lang = '.(int)$id_lang
|
||||
|
||||
@@ -211,7 +211,7 @@ class SearchCore
|
||||
INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category`
|
||||
INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category`
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product`
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
WHERE c.`active` = 1
|
||||
AND p.`active` = 1
|
||||
AND indexed = 1
|
||||
@@ -601,7 +601,7 @@ class SearchCore
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT pt.`id_product`) nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
|
||||
@@ -630,7 +630,7 @@ class SearchCore
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
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_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
|
||||
@@ -118,7 +118,7 @@ class SupplierCore extends ObjectModel
|
||||
$query = 'SELECT s.*, sl.`description`';
|
||||
$query .= ' FROM `'._DB_PREFIX_.'supplier` as s
|
||||
LEFT JOIN `'._DB_PREFIX_.'supplier_lang` sl ON (s.`id_supplier` = sl.`id_supplier` AND sl.`id_lang` = '.(int)$id_lang.')
|
||||
'.Context::getContext()->shop->addSqlAssociation('supplier', 's').'
|
||||
'.Shop::addSqlAssociation('supplier', 's').'
|
||||
'.($active ? ' WHERE s.`active` = 1 ' : '');
|
||||
$query .= ' ORDER BY s.`name` ASC'.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : '');
|
||||
$suppliers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
@@ -137,7 +137,7 @@ class TagCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product_tag` pt
|
||||
LEFT JOIN `'._DB_PREFIX_.'tag` t ON (t.id_tag = pt.id_tag)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = pt.id_product)
|
||||
'.Context::getContext()->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE t.`id_lang` = '.(int)$id_lang.'
|
||||
AND p.`active` = 1
|
||||
AND p.`id_product` IN (
|
||||
|
||||
@@ -730,7 +730,7 @@ class ShopCore extends ObjectModel
|
||||
* @param Context $context
|
||||
* @return string
|
||||
*/
|
||||
public function addSqlAssociation($table, $alias, $inner_join = true)
|
||||
public static function addSqlAssociation($table, $alias, $inner_join = true)
|
||||
{
|
||||
$table_alias = ' asso_shop_'.$table;
|
||||
if (strpos($table, '.') !== false)
|
||||
|
||||
@@ -92,7 +92,7 @@ class StoresControllerCore extends FrontController
|
||||
$stores = Db::getInstance()->executeS('
|
||||
SELECT s.*, cl.name country, st.iso_code state
|
||||
FROM '._DB_PREFIX_.'store s
|
||||
'.$this->context->shop->addSqlAssociation('shop', 's').'
|
||||
'.Shop::addSqlAssociation('shop', 's').'
|
||||
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
|
||||
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id);
|
||||
@@ -118,7 +118,7 @@ class StoresControllerCore extends FrontController
|
||||
$stores = Db::getInstance()->executeS('
|
||||
SELECT s.*, cl.name country, st.iso_code state
|
||||
FROM '._DB_PREFIX_.'store s
|
||||
'.$this->context->shop->addSqlAssociation('shop', 's').'
|
||||
'.Shop::addSqlAssociation('shop', 's').'
|
||||
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
|
||||
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id);
|
||||
@@ -141,7 +141,7 @@ class StoresControllerCore extends FrontController
|
||||
) distance,
|
||||
cl.id_country id_country
|
||||
FROM '._DB_PREFIX_.'store s
|
||||
'.$this->context->shop->addSqlAssociation('shop', 's').'
|
||||
'.Shop::addSqlAssociation('shop', 's').'
|
||||
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
|
||||
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.'
|
||||
|
||||
@@ -2288,7 +2288,7 @@ class BlockLayered extends Module
|
||||
}
|
||||
|
||||
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||
$queryFiltersFrom .= Context::getContext()->shop->addSqlAssociation('product', 'p');
|
||||
$queryFiltersFrom .= Shop::addSqlAssociation('product', 'p');
|
||||
|
||||
$allProductsOut = self::query('
|
||||
SELECT p.`id_product` id_product
|
||||
@@ -2624,7 +2624,7 @@ class BlockLayered extends Module
|
||||
if (!empty($sqlQuery['from']))
|
||||
{
|
||||
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||
$sqlQuery['from'] .= Context::getContext()->shop->addSqlAssociation('product', 'p');
|
||||
$sqlQuery['from'] .= Shop::addSqlAssociation('product', 'p');
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sqlQuery['select']."\n".$sqlQuery['from']."\n".$sqlQuery['join']."\n".$sqlQuery['where']."\n".$sqlQuery['group']);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class StatsBestProducts extends ModuleGrid
|
||||
AND dr.time_end BETWEEN '.$dateBetween.'
|
||||
) AS totalPageViewed
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.$this->context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->getLang().Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN '._DB_PREFIX_.'order_detail od ON od.product_id = p.id_product
|
||||
LEFT JOIN '._DB_PREFIX_.'orders o ON od.id_order = o.id_order
|
||||
|
||||
@@ -144,7 +144,7 @@ class StatsCatalog extends Module
|
||||
$this->_join = ' LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)';
|
||||
$this->_where = ' AND cp.`id_category` = '.$id_category;
|
||||
}
|
||||
$this->_join .= $this->context->shop->addSqlAssociation('product', 'p');
|
||||
$this->_join .= Shop::addSqlAssociation('product', 'p');
|
||||
|
||||
$result1 = $this->getQuery1(true);
|
||||
$total = $result1['total'];
|
||||
|
||||
@@ -99,7 +99,7 @@ class StatsCheckUp extends Module
|
||||
// Get languages
|
||||
$sql = 'SELECT l.*
|
||||
FROM '._DB_PREFIX_.'lang l'
|
||||
.$this->context->shop->addSqlAssociation('lang', 'l');
|
||||
.Shop::addSqlAssociation('lang', 'l');
|
||||
$languages = $db->executeS($sql);
|
||||
|
||||
$arrayColors = array(
|
||||
@@ -126,7 +126,7 @@ class StatsCheckUp extends Module
|
||||
$sql = 'SELECT p.id_product, p.active, pl.name, (
|
||||
SELECT COUNT(*)
|
||||
FROM '._DB_PREFIX_.'image i
|
||||
'.$this->context->shop->addSqlAssociation('image', 'i').'
|
||||
'.Shop::addSqlAssociation('image', 'i').'
|
||||
WHERE i.id_product = p.id_product
|
||||
) as nbImages, (
|
||||
SELECT SUM(od.product_quantity)
|
||||
@@ -141,7 +141,7 @@ class StatsCheckUp extends Module
|
||||
'.Product::sqlStock('p', 0).'
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl
|
||||
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').')
|
||||
'.$this->context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
ORDER BY '.$orderBy;
|
||||
$result = $db->executeS($sql);
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ class StatsForecast extends Module
|
||||
$langValues = '';
|
||||
$sql = 'SELECT l.id_lang, l.iso_code
|
||||
FROM `'._DB_PREFIX_.'lang` l
|
||||
'.$this->context->shop->addSqlAssociation('lang', 'l').'
|
||||
'.Shop::addSqlAssociation('lang', 'l').'
|
||||
WHERE l.active = 1';
|
||||
$languages = Db::getInstance()->executeS($sql);
|
||||
foreach ($languages as $language)
|
||||
|
||||
@@ -103,7 +103,7 @@ class StatsProduct extends ModuleGraph
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Product::sqlStock('p', 0).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
'.$this->context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
'.(Tools::getValue('id_category') ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`' : '').'
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
'.(Tools::getValue('id_category') ? 'AND cp.id_category = '.(int)Tools::getValue('id_category') : '').'
|
||||
|
||||
@@ -68,7 +68,7 @@ class StatsStock extends Module
|
||||
), p.wholesale_price) as wholesale_price,
|
||||
IFNULL(stock.quantity, 0) as quantity
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.$this->context->shop->addSqlAssociation('product', 'p').'
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
INNER JOIN '._DB_PREFIX_.'product_lang pl
|
||||
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').')
|
||||
'.Product::sqlStock('p', 0).'
|
||||
|
||||
Reference in New Issue
Block a user