// Replace shop->sqlAsso(), shop->sqlLang() and shop->sqlRestriction() with shop->addSqlAssociation(), shop->addSqlRestrictionOnLang() and shop->addSqlRestriction()

This commit is contained in:
rMalie
2011-10-17 09:46:08 +00:00
parent b0be0dd5ab
commit e6f45e54a6
60 changed files with 205 additions and 197 deletions
+2 -2
View File
@@ -159,7 +159,7 @@ class BlockCategories extends Module
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->sqlLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
@@ -232,7 +232,7 @@ class BlockCategories extends Module
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->sqlLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
+2 -2
View File
@@ -104,10 +104,10 @@ class BlockViewed extends Module
$productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT i.id_image, p.id_product, il.legend, p.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.$this->context->shop->sqlLang('pl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.$this->context->shop->addSqlRestrictionOnLang('pl').')
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 (il.id_image = i.id_image)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
WHERE p.id_product IN ('.$productIds.')
AND pl.id_lang = '.(int)($params['cookie']->id_lang).'
AND cl.id_lang = '.(int)($params['cookie']->id_lang)
+2 -2
View File
@@ -250,9 +250,9 @@ class WishList extends ObjectModel
SELECT wp.`id_product`, wp.`quantity`, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM `'._DB_PREFIX_.'wishlist_product` wp
JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product`
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Context::getContext()->shop->sqlLang('pl').'
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist`
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = p.`id_category_default` AND cl.id_lang='.(int)$id_lang.Context::getContext()->shop->sqlLang('cl').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = p.`id_category_default` AND cl.id_lang='.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
WHERE w.`id_customer` = '.(int)($id_customer).'
AND pl.`id_lang` = '.(int)($id_lang).'
AND wp.`id_wishlist` = '.(int)($id_wishlist).
+2 -2
View File
@@ -629,7 +629,7 @@ class CanadaPost extends CarrierModule
$categories = Db::getInstance()->executeS('
SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)$this->context->language->id.'
ORDER BY c.level_depth ASC
LIMIT '.(int)($category['level_depth'] + 1));
@@ -1015,7 +1015,7 @@ class CanadaPost extends CarrierModule
<option value="0">'.$this->l('Select a product ...').'</option>';
$productsList = Db::getInstance()->executeS('
SELECT pl.* FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+4 -4
View File
@@ -142,8 +142,8 @@ class CrossSelling extends Module
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->sqlLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id NOT IN ('.$list_product_ids.') AND i.cover = 1 AND p.active = 1
@@ -190,8 +190,8 @@ class CrossSelling extends Module
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->sqlLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id != '.(int)$params['product']->id.' AND i.cover = 1 AND p.active = 1
+2 -2
View File
@@ -1044,14 +1044,14 @@ class Ebay extends Module
$categoryConfigListTmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'ebay_category_configuration`');
foreach ($categoryConfigListTmp as $c)
$categoryConfigList[$c['id_category']] = $c;
$categoryList = Db::getInstance()->executeS('SELECT `id_category`, `name` FROM `'._DB_PREFIX_.'category_lang` WHERE `id_lang` = '.(int)$this->id_lang.$this->context->shop->sqlLang('cl'));
$categoryList = Db::getInstance()->executeS('SELECT `id_category`, `name` FROM `'._DB_PREFIX_.'category_lang` WHERE `id_lang` = '.(int)$this->id_lang.$this->context->shop->addSqlRestrictionOnLang('cl'));
foreach ($categoryList as $k => $c)
if (!isset($categoryConfigList[$c['id_category']]))
{
$productTest = Db::getInstance()->getRow('
SELECT pl.`name`, pl.`description`
FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->id_lang.$this->context->shop->sqlLang('pl').')
FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE `id_category_default` = '.(int)$c['id_category']);
$id_category_ref_suggested = $ebay->getSuggestedCategories($c['name'].' '.$productTest['name']);
$id_ebay_category_suggested = Db::getInstance()->getValue('SELECT `id_ebay_category` FROM `'._DB_PREFIX_.'ebay_category` WHERE `id_category_ref` = '.(int)$id_category_ref_suggested);
+2 -2
View File
@@ -75,12 +75,12 @@ class FavoriteProduct extends ObjectModel
SELECT fp.`id_shop`, p.`id_product`, pl.`description_short`, pl.`link_rewrite`, pl.`name`, i.`id_image`, CONCAT(p.`id_product`, \'-\', i.`id_image`) as image
FROM `'._DB_PREFIX_.'favorite_product` fp
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = fp.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$shop->addSqlRestrictionOnLang('pl').')
LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND `default_on` = 1)
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).')
WHERE p.`active` = 1
'.$shop->sqlRestriction(false, 'fp'));
'.$shop->addSqlRestriction(false, 'fp'));
}
public static function getFavoriteProduct($id_customer, $id_product, Shop $shop = null)
+2 -2
View File
@@ -725,7 +725,7 @@ class FedexCarrier extends CarrierModule
$categories = Db::getInstance()->executeS('
SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)$this->context->language->id.'
ORDER BY c.level_depth ASC
LIMIT '.(int)($category['level_depth'] + 1));
@@ -1170,7 +1170,7 @@ class FedexCarrier extends CarrierModule
<option value="0">'.$this->l('Select a product ...').'</option>';
$productsList = Db::getInstance()->executeS('
SELECT pl.* FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+2 -2
View File
@@ -327,7 +327,7 @@ class MailAlerts extends Module
$sql = 'SELECT id_product, quantity
FROM '._DB_PREFIX_.'stock_available
WHERE id_product_attribute = '.(int)$params['id_product_attribute']
.Context::getContext()->shop->sqlRestriction(Shop::SHARE_STOCK);
.Context::getContext()->shop->addSqlRestriction(Shop::SHARE_STOCK);
$result = Db::getInstance()->getRow($sql);
if ($this->_customer_qty AND $result['quantity'] > 0)
@@ -494,7 +494,7 @@ class MailAlerts extends Module
$sql = 'SELECT ma.`id_product`, stock.quantity AS product_quantity, pl.`name`, ma.`id_product_attribute`
FROM `'._DB_PREFIX_.'mailalert_customer_oos` ma
JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ma.`id_product`
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = ma.`id_product` AND pl.`id_lang` = '.$id_lang.Context::getContext()->shop->sqlLang('pl').'
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = ma.`id_product` AND pl.`id_lang` = '.$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
'.Product::sqlStock('p', 0).'
WHERE p.`active` = 1
ma.`id_customer` = '.$id_customer;
+3 -3
View File
@@ -254,7 +254,7 @@ class ProductComment extends ObjectModel
SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
FROM `'._DB_PREFIX_.'product_comment` pc
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
WHERE pc.`validate` = '.(int)$validate.'
ORDER BY pc.`date_add` DESC'));
}
@@ -270,7 +270,7 @@ class ProductComment extends ObjectModel
SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
FROM `'._DB_PREFIX_.'product_comment` pc
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
ORDER BY pc.`date_add` DESC'));
}
@@ -397,7 +397,7 @@ class ProductComment extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'product_comment` pc
ON pcr.id_product_comment = pc.id_product_comment
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
ORDER BY pc.`date_add` DESC');
}
+1 -1
View File
@@ -203,7 +203,7 @@ class Secuvad_flux
FROM `'._DB_PREFIX_.'secuvad_assoc_category` sac
JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = sac.`id_category`)
JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = cp.`id_category`)
JOIN `'._DB_PREFIX_.'product_lang` pl ON (cp.`id_product` = pl.`id_product`'.$this->context->shop->sqlLang('pl').')
JOIN `'._DB_PREFIX_.'product_lang` pl ON (cp.`id_product` = pl.`id_product`'.$this->context->shop->addSqlRestrictionOnLang('pl').')
JOIN `'._DB_PREFIX_.'lang` l ON (l.`id_lang` = pl.`id_lang` AND l.`id_lang` = '.(int)Context::getContext()->language->id.')
WHERE pl.`id_product` = '.(int)($product['product_id']).'
ORDER BY c.`level_depth` DESC
+1 -1
View File
@@ -1109,7 +1109,7 @@ class Secuvad extends Module
$module_not_assoc = Db::getInstance()->executeS('
SELECT cl.`name`, c.`id_category`
FROM `'._DB_PREFIX_.'category` c
JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`'.$this->context->shop->sqlLang('cl').')
JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = c.`id_category`'.$this->context->shop->addSqlRestrictionOnLang('cl').')
JOIN `'._DB_PREFIX_.'lang` l ON (l.`id_lang` = cl.`id_lang` AND l.`iso_code` = \'en\')
JOIN `'._DB_PREFIX_.'secuvad_assoc_category` sac ON (sac.`id_category` = c.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'secuvad_category` sc ON (sc.`category_id` = sac.`category_id` AND sc.`id_lang` = '.(int)$this->context->language->id.')
@@ -170,8 +170,8 @@ class StatsBestCategories extends ModuleGrid
AND dr.`time_end` BETWEEN '.$dateBetween.'
) AS totalPageViewed
FROM `'._DB_PREFIX_.'category` ca
LEFT JOIN `'._DB_PREFIX_.'category_lang` calang ON (ca.`id_category` = calang.`id_category` AND calang.`id_lang` = '.(int)$id_lang.$this->context->shop->sqlLang('calang').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` parent ON (ca.`id_parent` = parent.`id_category` AND parent.`id_lang` = '.(int)$id_lang.$this->context->shop->sqlLang('parent').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` calang ON (ca.`id_category` = calang.`id_category` AND calang.`id_lang` = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('calang').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` parent ON (ca.`id_parent` = parent.`id_category` AND parent.`id_lang` = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('parent').')
LEFT JOIN `'._DB_PREFIX_.'category_product` capr ON ca.`id_category` = capr.`id_category`
LEFT JOIN (
SELECT pr.`id_product`, t.`totalQuantitySold`, t.`totalPriceSold`
@@ -164,8 +164,8 @@ class StatsBestProducts extends ModuleGrid
AND dr.time_end BETWEEN '.$dateBetween.'
) AS totalPageViewed
FROM '._DB_PREFIX_.'product p
'.$this->context->shop->sqlAsso('product', 'p').'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->getLang().$this->context->shop->sqlLang('pl').')
'.$this->context->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().$this->context->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
WHERE p.active = 1
+2 -2
View File
@@ -123,7 +123,7 @@ class StatsCatalog extends Module
$sql = 'SELECT p.id_product, pl.name, pl.link_rewrite
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
'.$this->_join.'
WHERE p.`active` = 1
'.(sizeof($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').'
@@ -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->sqlAsso('product', 'p');
$this->_join .= $this->context->shop->addSqlAssociation('product', 'p');
$result1 = $this->getQuery1(true);
$total = $result1['total'];
+5 -5
View File
@@ -80,7 +80,7 @@ class StatsCheckUp extends Module
// Get languages
$sql = 'SELECT l.*
FROM '._DB_PREFIX_.'lang l'
.$this->context->shop->sqlAsso('lang', 'l');
.$this->context->shop->addSqlAssociation('lang', 'l');
$languages = $db->executeS($sql);
$arrayColors = array(
@@ -107,7 +107,7 @@ class StatsCheckUp extends Module
$sql = 'SELECT p.id_product, p.active, pl.name, (
SELECT COUNT(*)
FROM '._DB_PREFIX_.'image i
'.$this->context->shop->sqlAsso('image', 'i').'
'.$this->context->shop->addSqlAssociation('image', 'i').'
WHERE i.id_product = p.id_product
) as nbImages, (
SELECT SUM(od.product_quantity)
@@ -122,8 +122,8 @@ class StatsCheckUp extends Module
WHERE pa.id_product = p.id_product
), p.quantity) as stock
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->sqlLang('pl').')
'.$this->context->shop->sqlAsso('product', 'p').'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
'.$this->context->shop->addSqlAssociation('product', 'p').'
ORDER BY '.$orderBy;
$result = $db->executeS($sql);
@@ -194,7 +194,7 @@ class StatsCheckUp extends Module
$totals['images'] += (int)$scores['images'];
$totals['sales'] += (int)$scores['sales'];
$totals['stock'] += (int)$scores['stock'];
$descriptions = $db->executeS('SELECT l.iso_code, pl.description FROM '._DB_PREFIX_.'product_lang pl LEFT JOIN '._DB_PREFIX_.'lang l ON pl.id_lang = l.id_lang WHERE id_product = '.(int)$row['id_product'].$this->context->shop->sqlLang('pl'));
$descriptions = $db->executeS('SELECT l.iso_code, pl.description FROM '._DB_PREFIX_.'product_lang pl LEFT JOIN '._DB_PREFIX_.'lang l ON pl.id_lang = l.id_lang WHERE id_product = '.(int)$row['id_product'].$this->context->shop->addSqlRestrictionOnLang('pl'));
foreach ($descriptions as $description)
{
$row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description']));
+2 -2
View File
@@ -497,7 +497,7 @@ class StatsForecast extends Module
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = od.product_id
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.$this->context->shop->sqlLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('cl').')
'.$join.'
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
@@ -510,7 +510,7 @@ class StatsForecast extends Module
$langValues = '';
$sql = 'SELECT l.id_lang, l.iso_code
FROM `'._DB_PREFIX_.'lang` l
'.$this->context->shop->sqlAsso('lang', 'l').'
'.$this->context->shop->addSqlAssociation('lang', 'l').'
WHERE l.active = 1';
$languages = Db::getInstance()->executeS($sql);
foreach ($languages as $language)
+3 -3
View File
@@ -102,8 +102,8 @@ class StatsProduct extends ModuleGraph
$sql = 'SELECT p.`id_product`, p.reference, pl.`name`, IFNULL(
(SELECT SUM(pa.quantity) FROM '._DB_PREFIX_.'product_attribute pa WHERE pa.id_product = p.id_product), p.quantity) as quantity
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.$this->context->shop->sqlLang('pl').'
'.$this->context->shop->sqlAsso('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.$this->context->shop->addSqlRestrictionOnLang('pl').'
'.$this->context->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')) : '').'
@@ -128,7 +128,7 @@ class StatsProduct extends ModuleGraph
$sql = 'SELECT pl.name as pname, pl.id_product, SUM(od.product_quantity) as pqty, AVG(od.product_price) as pprice
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = od.product_id AND pl.id_lang = '.(int)$id_lang.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = od.product_id AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE o.id_customer IN (
SELECT o.id_customer
FROM `'._DB_PREFIX_.'orders` o
+2 -2
View File
@@ -73,8 +73,8 @@ class StatsStock extends Module
FROM '._DB_PREFIX_.'product_attribute pa WHERE p.id_product = pa.id_product
), p.wholesale_price * p.quantity) as stockvalue
FROM '._DB_PREFIX_.'product p
'.$this->context->shop->sqlAsso('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.$this->context->shop->sqlLang('pl').')
'.$this->context->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.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE 1 = 1
'.$filter;
$products = Db::getInstance()->executeS($sql);
+1 -1
View File
@@ -302,7 +302,7 @@ XML;
$categories = Db::getInstance()->executeS('
SELECT cl.name, l.iso_code
FROM '._DB_PREFIX_.'category_product cp
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = cp.id_category'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = cp.id_category'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'lang l ON (l.id_lang = cl.id_lang)
WHERE cp.id_product = '.(int)$sqlProduct['id_product']);
+2 -2
View File
@@ -742,7 +742,7 @@ class UpsCarrier extends CarrierModule
$categories = Db::getInstance()->executeS('
SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)$this->context->language->id.'
ORDER BY c.level_depth ASC
LIMIT '.(int)($category['level_depth'] + 1));
@@ -1158,7 +1158,7 @@ class UpsCarrier extends CarrierModule
<option value="0">'.$this->l('Select a product ...').'</option>';
$productsList = Db::getInstance()->executeS('
SELECT pl.* FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 2'.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 2'.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+2 -2
View File
@@ -673,7 +673,7 @@ class UspsCarrier extends CarrierModule
$categories = Db::getInstance()->executeS('
SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->sqlLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$this->context->shop->addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)($this->context->language->id).'
ORDER BY c.level_depth ASC
LIMIT '.(int)($category['level_depth'] + 1));
@@ -1147,7 +1147,7 @@ class UspsCarrier extends CarrierModule
<option value="0">'.$this->l('Select a product ...').'</option>';
$productsList = Db::getInstance()->executeS('
SELECT pl.* FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)