// Fix all product_lang sql restrictions with multishop

This commit is contained in:
rMalie
2011-08-19 14:01:23 +00:00
parent e3f21b76e6
commit fb55cfcd11
26 changed files with 146 additions and 141 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ 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)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.$this->context->shop->sqlLang('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)
+1 -1
View File
@@ -250,7 +250,7 @@ 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`
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Context::getContext()->shop->sqlLang('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.'
WHERE w.`id_customer` = '.(int)($id_customer).'
+1 -1
View File
@@ -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.')
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').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+1 -1
View File
@@ -122,7 +122,7 @@ 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)
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)
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.'
+1 -1
View File
@@ -992,7 +992,7 @@ class Ebay extends Module
{
$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.')
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').')
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);
+1 -1
View File
@@ -75,7 +75,7 @@ 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->sqlLang('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).')
+1 -1
View File
@@ -1169,7 +1169,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.')
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').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+1 -1
View File
@@ -217,7 +217,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`)
JOIN `'._DB_PREFIX_.'product_lang` pl ON (cp.`id_product` = pl.`id_product`'.$this->context->shop->sqlLang('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
@@ -165,7 +165,7 @@ class StatsBestProducts extends ModuleGrid
) 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()).')
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').')
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
+1 -1
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).')
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').')
'.$this->_join.'
WHERE p.`active` = 1
'.(sizeof($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').'
+2 -2
View File
@@ -122,7 +122,7 @@ 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.')
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').'
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 iso_code, 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']);
$descriptions = $db->ExecuteS('SELECT iso_code, description FROM '._DB_PREFIX_.'product_lang pl LEFT JOIN '._DB_PREFIX_.'lang l ON pl.id_lang = l.id_lang'.$this->context->shop->sqlLang('pl').' WHERE id_product = '.(int)$row['id_product']);
foreach ($descriptions as $description)
{
$row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description']));
+2 -2
View File
@@ -102,7 +102,7 @@ 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`
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').'
'.(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).'
@@ -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).')
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').')
WHERE o.id_customer IN (
SELECT o.id_customer
FROM `'._DB_PREFIX_.'orders` o
+1 -1
View File
@@ -74,7 +74,7 @@ class StatsStock extends Module
), 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.')
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').')
WHERE 1 = 1
'.$filter;
$products = Db::getInstance()->ExecuteS($sql);
+1 -1
View File
@@ -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)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 2'.$this->context->shop->sqlLang('pl').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)
+1 -1
View File
@@ -1163,7 +1163,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.')
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').')
WHERE p.`active` = 1
ORDER BY pl.`name`');
foreach ($productsList as $product)