// Change prototype of methods from(), leftJoin(), innerJoin(), leftOuterJoin() and naturalJoin() for DbQuery class
This commit is contained in:
+2
-2
@@ -185,9 +185,9 @@ class CMSCore extends ObjectModel
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->select('*');
|
||||
$sql->from('cms c');
|
||||
$sql->from('cms', 'c');
|
||||
if ($id_lang)
|
||||
$sql->innerJoin('cms_lang l ON c.id_cms = l.id_cms AND l.id_lang = '.(int)$id_lang);
|
||||
$sql->innerJoin('cms_lang', 'l', 'c.id_cms = l.id_cms AND l.id_lang = '.(int)$id_lang);
|
||||
|
||||
if ($active)
|
||||
$sql->where('c.active = 1');
|
||||
|
||||
+2
-2
@@ -1024,8 +1024,8 @@ class CarrierCore extends ObjectModel
|
||||
// Does the product is linked with carriers?
|
||||
$query = new DbQuery();
|
||||
$query->select('id_carrier');
|
||||
$query->from('product_carrier pc');
|
||||
$query->innerJoin('carrier c ON (c.id_reference = pc.id_carrier_reference AND c.deleted = 0)');
|
||||
$query->from('product_carrier', 'pc');
|
||||
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
|
||||
$query->where('id_product = '.(int)($product->id));
|
||||
$query->where('id_shop = '.(int)$id_shop);
|
||||
$carriers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
+36
-36
@@ -383,27 +383,27 @@ class CartCore extends ObjectModel
|
||||
CONCAT(cp.`id_product`, cp.`id_product_attribute`, cp.`id_address_delivery`) AS unique_id, cp.id_address_delivery, p.`wholesale_price`');
|
||||
|
||||
// Build FROM
|
||||
$sql->from('cart_product cp');
|
||||
$sql->from('cart_product', 'cp');
|
||||
|
||||
// Build JOIN
|
||||
$sql->leftJoin('product p ON p.`id_product` = cp.`id_product`');
|
||||
$sql->leftJoin('product_lang pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('tax_rule tr
|
||||
ON p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
$sql->leftJoin('tax_rule', 'tr', '
|
||||
p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$id_country.'
|
||||
AND tr.`id_state` = 0
|
||||
AND tr.`zipcode_from` = 0'
|
||||
);
|
||||
$sql->leftJoin('tax t ON t.`id_tax` = tr.`id_tax`');
|
||||
$sql->leftJoin('tax_lang tl
|
||||
ON t.`id_tax` = tl.`id_tax`
|
||||
$sql->leftJoin('tax', 't', 't.`id_tax` = tr.`id_tax`');
|
||||
$sql->leftJoin('tax_lang', 'tl', '
|
||||
t.`id_tax` = tl.`id_tax`
|
||||
AND tl.`id_lang` = '.(int)$this->id_lang
|
||||
);
|
||||
$sql->leftJoin('category_lang cl
|
||||
ON p.`id_category_default` = cl.`id_category`
|
||||
$sql->leftJoin('category_lang', 'cl', '
|
||||
p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl')
|
||||
);
|
||||
|
||||
@@ -425,7 +425,7 @@ class CartCore extends ObjectModel
|
||||
if (Customization::isFeatureActive())
|
||||
{
|
||||
$sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
|
||||
$sql->leftJoin('customization cu ON p.`id_product` = cu.`id_product`');
|
||||
$sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product`');
|
||||
}
|
||||
else
|
||||
$sql->select('0 AS customization_quantity');
|
||||
@@ -444,9 +444,9 @@ class CartCore extends ObjectModel
|
||||
pa.`ecotax` AS ecotax_attr'
|
||||
);
|
||||
|
||||
$sql->leftJoin('product_attribute pa ON pa.`id_product_attribute` = cp.`id_product_attribute`');
|
||||
$sql->leftJoin('product_attribute_image pai ON pai.`id_product_attribute` = pa.`id_product_attribute`');
|
||||
$sql->leftJoin('image_lang il ON il.id_image = pai.id_image AND il.id_lang = '.(int)$this->id_lang);
|
||||
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
|
||||
$sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`');
|
||||
$sql->leftJoin('image_lang', 'il', 'il.id_image = pai.id_image AND il.id_lang = '.(int)$this->id_lang);
|
||||
}
|
||||
else
|
||||
$sql->select(
|
||||
@@ -1611,7 +1611,7 @@ class CartCore extends ObjectModel
|
||||
$best_price_carriers = array();
|
||||
$best_grade_carriers = array();
|
||||
$carriers_instance = array();
|
||||
|
||||
|
||||
foreach ($packages as $id_package => $package)
|
||||
{
|
||||
// No carriers available
|
||||
@@ -1772,36 +1772,36 @@ class CartCore extends ObjectModel
|
||||
$cache = $delivery_option_list;
|
||||
return $delivery_option_list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all deliveries options available for the current cart formated like Carriers::getCarriersForOrder
|
||||
* This method was wrote for retrocompatibility with 1.4 theme
|
||||
* New theme need to use Cart::getDeliveryOptionList() to generate carriers option in the checkout process
|
||||
*
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
*
|
||||
* @param Country $default_country
|
||||
* @param boolean $flush Force flushing cache
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function simulateCarriersOutput(Country $default_country = null, $flush = false)
|
||||
{
|
||||
static $cache = false;
|
||||
if ($cache !== false && !$flush)
|
||||
return $cache;
|
||||
|
||||
|
||||
$delivery_option_list = $this->getDeliveryOptionList($default_country, $flush);
|
||||
|
||||
|
||||
// This method cannot work if there is multiple address delivery
|
||||
if (count($delivery_option_list) > 1 || empty($delivery_option_list))
|
||||
return array();
|
||||
|
||||
|
||||
$carriers = array();
|
||||
foreach (reset($delivery_option_list) as $key => $option)
|
||||
{
|
||||
$price = $option['total_price_with_tax'];
|
||||
$price_tax_exc = $option['total_price_without_tax'];
|
||||
|
||||
|
||||
if ($option['unique_carrier'])
|
||||
{
|
||||
$carrier = reset($option['carrier_list']);
|
||||
@@ -1831,24 +1831,24 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
return $carriers;
|
||||
}
|
||||
|
||||
|
||||
public function simulateCarrierSelectedOutput()
|
||||
{
|
||||
$delivery_option = $this->getDeliveryOption();
|
||||
|
||||
|
||||
if (count($delivery_option) > 1 || empty($delivery_option))
|
||||
return 0;
|
||||
|
||||
|
||||
return self::intifier(reset($delivery_option));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate a string option_delivery identifier ('24,3,') in a int (3240002000)
|
||||
*
|
||||
*
|
||||
* The option_delivery identifier is a list of integers separated by a ','.
|
||||
* This method replace the delimiter by a sequence of '0'.
|
||||
* The size of this sequence is fixed by the first digit of the return
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function intifier($string, $delimiter = ',')
|
||||
@@ -1857,7 +1857,7 @@ class CartCore extends ObjectModel
|
||||
$max = max($elm);
|
||||
return strlen($max).join(str_repeat('0', strlen($max)+1), $elm);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate a int option_delivery identifier (3240002000) in a string ('24,3,')
|
||||
*/
|
||||
@@ -1877,7 +1877,7 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->select('count(distinct id_address_delivery)');
|
||||
$sql->from('cart_product as cp');
|
||||
$sql->from('cart_product', 'cp');
|
||||
$sql->where('id_cart = '.(int)$this->id);
|
||||
|
||||
return Db::getInstance()->getValue($sql) > 1;
|
||||
@@ -2754,7 +2754,7 @@ class CartCore extends ObjectModel
|
||||
// Checking if the product with the old address delivery exists
|
||||
$sql = new DbQuery();
|
||||
$sql->select('count(*)');
|
||||
$sql->from('cart_product as cp');
|
||||
$sql->from('cart_product', 'cp');
|
||||
$sql->where('id_product = '.(int)$id_product);
|
||||
$sql->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$sql->where('id_address_delivery = '.(int)$old_id_address_delivery);
|
||||
@@ -2767,7 +2767,7 @@ class CartCore extends ObjectModel
|
||||
// Checking if there is no others similar products with this new address delivery
|
||||
$sql = new DbQuery();
|
||||
$sql->select('sum(quantity) as qty');
|
||||
$sql->from('cart_product as cp');
|
||||
$sql->from('cart_product', 'cp');
|
||||
$sql->where('id_product = '.(int)$id_product);
|
||||
$sql->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$sql->where('id_address_delivery = '.(int)$new_id_address_delivery);
|
||||
@@ -2816,7 +2816,7 @@ class CartCore extends ObjectModel
|
||||
// Checking the product do not exist with the new address
|
||||
$sql = new DbQuery();
|
||||
$sql->select('count(*)');
|
||||
$sql->from('cart_product as c');
|
||||
$sql->from('cart_product', 'c');
|
||||
$sql->where('id_product = '.(int)$id_product);
|
||||
$sql->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$sql->where('id_address_delivery = '.(int)$new_id_address_delivery);
|
||||
@@ -2855,7 +2855,7 @@ class CartCore extends ObjectModel
|
||||
// Checking if there is customizations
|
||||
$sql = new DbQuery();
|
||||
$sql->select('*');
|
||||
$sql->from('customization as c');
|
||||
$sql->from('customization', 'c');
|
||||
$sql->where('id_product = '.(int)$id_product);
|
||||
$sql->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$sql->where('id_address_delivery = '.(int)$id_address_delivery);
|
||||
|
||||
@@ -89,13 +89,13 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
|
||||
|
||||
$this->query = new DbQuery();
|
||||
$this->query->select('a.*');
|
||||
$this->query->from($this->definition['table'].' a');
|
||||
$this->query->from($this->definition['table'], 'a');
|
||||
|
||||
// If multilang, create association to lang table
|
||||
if (isset($this->definition['multilang']) && $this->definition['multilang'])
|
||||
{
|
||||
$this->query->select('b.*');
|
||||
$this->query->leftJoin($this->definition['table'].'_lang b ON a.'.$this->definition['primary'].' = b.'.$this->definition['primary']);
|
||||
$this->query->leftJoin($this->definition['table'].'_lang', 'b', 'a.'.$this->definition['primary'].' = b.'.$this->definition['primary']);
|
||||
if ($this->id_lang)
|
||||
$this->query->where('b.id_lang = '.(int)$this->id_lang);
|
||||
}
|
||||
|
||||
@@ -173,11 +173,11 @@ abstract class ObjectModelCore
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->from($this->def['table'].' a');
|
||||
$sql->from($this->def['table'], 'a');
|
||||
$sql->where('a.'.$this->def['primary'].' = '.(int)$id);
|
||||
if ($id_lang)
|
||||
{
|
||||
$sql->leftJoin($this->def['table'].'_lang b ON a.'.$this->def['primary'].' = b.'.$this->def['primary'].' AND b.id_lang = '.(int)$id_lang);
|
||||
$sql->leftJoin($this->def['table'].'_lang', 'b', 'a.'.$this->def['primary'].' = b.'.$this->def['primary'].' AND b.id_lang = '.(int)$id_lang);
|
||||
if ($this->id_shop)
|
||||
$sql->where('b.id_shop = '.$this->id_shop);
|
||||
}
|
||||
@@ -1119,7 +1119,7 @@ abstract class ObjectModelCore
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('`id_'.pSQL($table).'`');
|
||||
$query->from(pSQL($table));
|
||||
$query->from($table);
|
||||
if ($has_active_column)
|
||||
$query->where('`active` = 1');
|
||||
return (bool)Db::getInstance()->getValue($query);
|
||||
|
||||
+26
-26
@@ -1815,21 +1815,21 @@ class ProductCore extends ObjectModel
|
||||
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice'
|
||||
);
|
||||
|
||||
$sql->from('product p');
|
||||
$sql->from('product', 'p');
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang pl ON (
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').')'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('image i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)');
|
||||
$sql->leftJoin('image_lang il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')');
|
||||
$sql->leftJoin('tax_rule tr ON (
|
||||
$sql->leftJoin('image', 'i', 'i.`id_product` = p.`id_product` AND i.`cover` = 1');
|
||||
$sql->leftJoin('image_lang', 'il', 'i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang);
|
||||
$sql->leftJoin('tax_rule', 'tr', '
|
||||
p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$context->country->id.'
|
||||
AND tr.`id_state` = 0)'
|
||||
AND tr.`id_state` = 0'
|
||||
);
|
||||
$sql->leftJoin('tax t ON (t.`id_tax` = tr.`id_tax`)');
|
||||
$sql->leftJoin('manufacturer m ON (m.`id_manufacturer` = p.`id_manufacturer`)');
|
||||
$sql->leftJoin('tax', 't', 't.`id_tax` = tr.`id_tax`');
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
Product::sqlStock('p', 0, false, null, $sql);
|
||||
|
||||
$sql->where('p.`active` = 1');
|
||||
@@ -1856,7 +1856,7 @@ class ProductCore extends ObjectModel
|
||||
if (Combination::isFeatureActive())
|
||||
{
|
||||
$sql->select('pa.id_product_attribute');
|
||||
$sql->leftOuterJoin('product_attribute pa ON (p.`id_product` = pa.`id_product` AND `default_on` = 1)');
|
||||
$sql->leftOuterJoin('product_attribute', 'pa', 'p.`id_product` = pa.`id_product` AND `default_on` = 1');
|
||||
}
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
@@ -2355,7 +2355,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->select('p.`price`, p.`ecotax`');
|
||||
$sql->from('product p');
|
||||
$sql->from('product', 'p');
|
||||
$sql->where('p.`id_product` = '.(int)$id_product);
|
||||
|
||||
if (Combination::isFeatureActive())
|
||||
@@ -2363,7 +2363,7 @@ class ProductCore extends ObjectModel
|
||||
if ($id_product_attribute)
|
||||
{
|
||||
$sql->select('pa.`price` AS attribute_price');
|
||||
$sql->leftJoin('product_attribute pa ON (pa.`id_product_attribute` = '.(int)$id_product_attribute.')');
|
||||
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = '.(int)$id_product_attribute);
|
||||
}
|
||||
else
|
||||
$sql->select(
|
||||
@@ -2613,7 +2613,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
// @todo remove this code when query builder is accepted or removed
|
||||
$method = ($inner_join) ? 'innerJoin' : 'leftJoin';
|
||||
$sql->$method('stock_available stock ON stock.id_product = '.pSQL($product_alias).'.id_product');
|
||||
$sql->$method('stock_available', 'stock', 'stock.id_product = '.pSQL($product_alias).'.id_product');
|
||||
if (!is_null($product_attribute))
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
@@ -3049,14 +3049,14 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = new DbQuery();
|
||||
$sql->select('p.`id_product`, pl.`name`, p.`active`, p.`reference`, m.`name` AS manufacturer_name, stock.`quantity`');
|
||||
$sql->from('category_product cp');
|
||||
$sql->leftJoin('product p ON p.`id_product` = cp.`id_product`');
|
||||
$sql->from('category_product', 'cp');
|
||||
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang pl ON (
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').')'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('manufacturer m ON m.`id_manufacturer` = p.`id_manufacturer`');
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
|
||||
$where = 'pl.`name` LIKE \'%'.pSQL($query).'%\' OR p.`reference` LIKE \'%'.pSQL($query).'%\' OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\'';
|
||||
$sql->groupBy('`id_product`');
|
||||
@@ -3064,7 +3064,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
if (Combination::isFeatureActive())
|
||||
{
|
||||
$sql->leftJoin('product_attribute pa ON pa.`id_product` = p.`id_product`');
|
||||
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product` = p.`id_product`');
|
||||
$where .= ' OR pa.`reference` LIKE \'%'.pSQL($query).'%\'';
|
||||
}
|
||||
$sql->where($where);
|
||||
@@ -4583,18 +4583,18 @@ class ProductCore extends ObjectModel
|
||||
|
||||
// queries different tables if it is a combination
|
||||
if ($id_product_attribute)
|
||||
$query->from('product_attribute pa');
|
||||
$query->from('product_attribute', 'pa');
|
||||
else
|
||||
$query->from('product_lang pl');
|
||||
$query->from('product_lang', 'pl');
|
||||
|
||||
// adds joins & where clauses for combinations
|
||||
if ($id_product_attribute)
|
||||
{
|
||||
$query->innerJoin('product_lang pl ON (pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang.')');
|
||||
$query->leftJoin('product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)');
|
||||
$query->leftJoin('attribute atr ON (atr.id_attribute = pac.id_attribute)');
|
||||
$query->leftJoin('attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.(int)$id_lang.')');
|
||||
$query->leftJoin('attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.(int)$id_lang.')');
|
||||
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang);
|
||||
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
|
||||
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
|
||||
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.(int)$id_lang);
|
||||
$query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.(int)$id_lang);
|
||||
$query->where('pa.id_product = '.(int)$id_product.' AND pa.id_product_attribute = '.(int)$id_product_attribute);
|
||||
}
|
||||
else // or just adds a 'where' clause for a simple product
|
||||
|
||||
@@ -88,7 +88,7 @@ class ProductSupplierCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('ps.product_supplier_reference');
|
||||
$query->from('product_supplier ps');
|
||||
$query->from('product_supplier', 'ps');
|
||||
$query->where('ps.id_product = '.(int)$id_product.'
|
||||
AND ps.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND ps.id_supplier = '.(int)$id_supplier
|
||||
@@ -110,7 +110,7 @@ class ProductSupplierCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('ps.product_supplier_price_te');
|
||||
$query->from('product_supplier ps');
|
||||
$query->from('product_supplier', 'ps');
|
||||
$query->where('ps.id_product = '.(int)$id_product.'
|
||||
AND ps.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND ps.id_supplier = '.(int)$id_supplier
|
||||
@@ -132,7 +132,7 @@ class ProductSupplierCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('ps.id_product_supplier');
|
||||
$query->from('product_supplier ps');
|
||||
$query->from('product_supplier', 'ps');
|
||||
$query->where('ps.id_product = '.(int)$id_product.'
|
||||
AND ps.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND ps.id_supplier = '.(int)$id_supplier
|
||||
|
||||
@@ -61,8 +61,8 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
public function delete()
|
||||
{
|
||||
$ids_condition_group = Db::getInstance()->executeS('SELECT id_specific_price_rule_condition_group
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group
|
||||
WHERE id_specific_price_rule='.(int)$this->id);
|
||||
FROM '._DB_PREFIX_.'specific_price_rule_condition_group
|
||||
WHERE id_specific_price_rule='.(int)$this->id);
|
||||
if ($ids_condition_group)
|
||||
foreach ($ids_condition_group as $row)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
{
|
||||
if (!is_array($conditions))
|
||||
return;
|
||||
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'specific_price_rule_condition_group` (`id_specific_price_rule_condition_group`, `id_specific_price_rule`)
|
||||
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'specific_price_rule_condition_group` (`id_specific_price_rule_condition_group`, `id_specific_price_rule`)
|
||||
VALUES(\'\', '.(int)$this->id.')'))
|
||||
return false;
|
||||
$id_specific_price_rule_condition_group = (int)Db::getInstance()->Insert_ID();
|
||||
@@ -87,7 +87,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'specific_price_rule_condition (id_specific_price_rule_condition, id_specific_price_rule_condition_group, type, value)
|
||||
VALUES(\'\', '.(int)$id_specific_price_rule_condition_group.', \''.pSQL($condition['type']).'\', \''.pSQL($condition['value']).'\')'))
|
||||
return false;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function apply($products = false)
|
||||
@@ -102,7 +102,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
{
|
||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE id_specific_price_rule='.(int)$this->id);
|
||||
}
|
||||
|
||||
|
||||
public static function applyAllRules($products = false)
|
||||
{
|
||||
$rules = new Collection('SpecificPriceRule');
|
||||
@@ -134,21 +134,21 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
}
|
||||
return $conditions_group;
|
||||
}
|
||||
|
||||
|
||||
public function getAffectedProducts($products = false)
|
||||
{
|
||||
$conditions_group = $this->getConditions();
|
||||
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('p.id_product');
|
||||
$query->from('product p');
|
||||
$query->from('product', 'p');
|
||||
$query->groupBy('p.id_product');
|
||||
|
||||
$attributes = false;
|
||||
$categories = false;
|
||||
$features = false;
|
||||
$where = false;
|
||||
|
||||
|
||||
if ($conditions_group)
|
||||
{
|
||||
$where = '(';
|
||||
@@ -190,17 +190,17 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
if ($attributes)
|
||||
{
|
||||
$query->select('pa.id_product_attribute');
|
||||
$query->leftJoin('product_attribute pa ON (p.id_product = pa.id_product)');
|
||||
$query->leftJoin('product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute)');
|
||||
$query->leftJoin('product_attribute', 'pa', 'p.id_product = pa.id_product');
|
||||
$query->leftJoin('product_attribute_combination', 'pac', 'pa.id_product_attribute = pac.id_product_attribute');
|
||||
$query->groupBy('pa.id_product_attribute');
|
||||
}
|
||||
else
|
||||
$query->select('NULL id_product_attribute');
|
||||
|
||||
if ($features)
|
||||
$query->leftJoin('feature_product fp ON (p.id_product = fp.id_product)');
|
||||
$query->leftJoin('feature_product', 'fp', 'p.id_product = fp.id_product');
|
||||
if ($categories)
|
||||
$query->leftJoin('category_product cp ON (p.id_product = cp.id_product)');
|
||||
$query->leftJoin('category_product', 'cp', 'p.id_product = cp.id_product');
|
||||
if ($where)
|
||||
$query->where($where);
|
||||
|
||||
|
||||
+10
-22
@@ -65,10 +65,10 @@ class DbQueryCore
|
||||
* @param string $table Table name
|
||||
* @return DbQuery
|
||||
*/
|
||||
public function from($table)
|
||||
public function from($table, $alias = null)
|
||||
{
|
||||
if (!empty($table))
|
||||
$this->query['from'] = _DB_PREFIX_.$table;
|
||||
$this->query['from'] = '`'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '');
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -93,12 +93,9 @@ class DbQueryCore
|
||||
*
|
||||
* @param string $join Table followed by ON claused
|
||||
*/
|
||||
public function leftJoin($join)
|
||||
public function leftJoin($table, $alias = null, $on = null)
|
||||
{
|
||||
if (!empty($join))
|
||||
return $this->join('LEFT JOIN '._DB_PREFIX_.$join);
|
||||
|
||||
return $this;
|
||||
return $this->join('LEFT JOIN `'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '').($on ? ' ON '.$on : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,12 +104,9 @@ class DbQueryCore
|
||||
*
|
||||
* @param string $join Table followed by ON claused
|
||||
*/
|
||||
public function innerJoin($join)
|
||||
public function innerJoin($table, $alias = null, $on = null)
|
||||
{
|
||||
if (!empty($join))
|
||||
return $this->join('INNER JOIN '._DB_PREFIX_.$join);
|
||||
|
||||
return $this;
|
||||
return $this->join('INNER JOIN `'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '').($on ? ' ON '.$on : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,12 +114,9 @@ class DbQueryCore
|
||||
*
|
||||
* @param string $join Table followed by ON claused
|
||||
*/
|
||||
public function leftOuterJoin($join)
|
||||
public function leftOuterJoin($table, $alias = null, $on = null)
|
||||
{
|
||||
if (!empty($join))
|
||||
return $this->join('LEFT OUTER JOIN '._DB_PREFIX_.$join);
|
||||
|
||||
return $this;
|
||||
return $this->join('LEFT OUTER JOIN `'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '').($on ? ' ON '.$on : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,12 +124,9 @@ class DbQueryCore
|
||||
*
|
||||
* @param string $join
|
||||
*/
|
||||
public function naturalJoin($join)
|
||||
public function naturalJoin($table, $alias = null, $on = null)
|
||||
{
|
||||
if (!empty($join))
|
||||
return $this->join('NATURAL JOIN '._DB_PREFIX_.$join);
|
||||
|
||||
return $this;
|
||||
return $this->join('NATURAL JOIN `'._DB_PREFIX_.$table.'`'.($alias ? ' '.$alias : '').($on ? ' ON '.$on : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -425,7 +425,7 @@ class StockManagerCore implements StockManagerInterface
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM('.($usable ? 's.usable_quantity' : 's.physical_quantity').')');
|
||||
$query->from('stock s');
|
||||
$query->from('stock', 's');
|
||||
$query->where('s.id_product = '.(int)$id_product);
|
||||
if (0 != $id_product_attribute)
|
||||
$query->where('s.id_product_attribute = '.(int)$id_product_attribute);
|
||||
@@ -456,13 +456,13 @@ class StockManagerCore implements StockManagerInterface
|
||||
// Gets client_orders_qty
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(od.product_quantity) + SUM(od.product_quantity_refunded)');
|
||||
$query->from('order_detail od');
|
||||
$query->leftjoin('orders o ON o.id_order = od.id_order');
|
||||
$query->from('order_detail', 'od');
|
||||
$query->leftjoin('orders', 'o', 'o.id_order = od.id_order');
|
||||
$query->where('od.product_id = '.(int)$id_product);
|
||||
if (0 != $id_product_attribute)
|
||||
$query->where('od.product_attribute_id = '.(int)$id_product_attribute);
|
||||
$query->leftJoin('order_history oh ON (oh.id_order = o.id_order AND oh.date_add = o.date_upd)');
|
||||
$query->leftJoin('order_state os ON (os.id_order_state = oh.id_order_state)');
|
||||
$query->leftJoin('order_history', 'oh', 'oh.id_order = o.id_order AND oh.date_add = o.date_upd');
|
||||
$query->leftJoin('order_state', 'os', 'os.id_order_state = oh.id_order_state');
|
||||
$query->where('os.shipped != 1');
|
||||
$query->where('o.valid = 1');
|
||||
// @FIXME: Once part-shipping is done, remove the comment on the line below.
|
||||
@@ -472,9 +472,9 @@ class StockManagerCore implements StockManagerInterface
|
||||
// Gets supply_orders_qty
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(sod.quantity_expected)');
|
||||
$query->from('supply_order so');
|
||||
$query->leftjoin('supply_order_detail sod ON (sod.id_supply_order = so.id_supply_order)');
|
||||
$query->leftjoin('supply_order_state sos ON (sos.id_supply_order_state = so.id_supply_order_state)');
|
||||
$query->from('supply_order', 'so');
|
||||
$query->leftjoin('supply_order_detail', 'sod', 'sod.id_supply_order = so.id_supply_order');
|
||||
$query->leftjoin('supply_order_state', 'sos', 'sos.id_supply_order_state = so.id_supply_order_state');
|
||||
$query->where('sos.pending_receipt = 1');
|
||||
$query->where('sod.id_product = '.(int)$id_product.' AND sod.id_product_attribute = '.(int)$id_product_attribute);
|
||||
if (count($ids_warehouse))
|
||||
|
||||
@@ -186,8 +186,8 @@ class StockMvtCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('sm.*, s.id_warehouse');
|
||||
$query->from('stock_mvt sm');
|
||||
$query->innerJoin('stock s ON (s.id_stock = sm.id_stock)');
|
||||
$query->from('stock_mvt', 'sm');
|
||||
$query->innerJoin('stock', 's', 's.id_stock = sm.id_stock');
|
||||
$query->where('sm.sign = -1');
|
||||
$query->where('sm.id_order = '.(int)$id_order);
|
||||
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
|
||||
|
||||
@@ -72,8 +72,8 @@ class StockMvtReasonCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('smrl.name, smr.id_stock_mvt_reason, smr.sign');
|
||||
$query->from('stock_mvt_reason smr');
|
||||
$query->leftjoin('stock_mvt_reason_lang smrl ON (smr.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang='.(int)$id_lang.')');
|
||||
$query->from('stock_mvt_reason', 'smr');
|
||||
$query->leftjoin('stock_mvt_reason_lang', 'smrl', 'smr.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang='.(int)$id_lang);
|
||||
$query->where('smr.deleted = 0');
|
||||
|
||||
if ($sign != null)
|
||||
@@ -94,8 +94,8 @@ class StockMvtReasonCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('smrl.name, smr.id_stock_mvt_reason, smr.sign');
|
||||
$query->from('stock_mvt_reason smr');
|
||||
$query->leftjoin('stock_mvt_reason_lang smrl ON (smr.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang='.(int)$id_lang.')');
|
||||
$query->from('stock_mvt_reason', 'smr');
|
||||
$query->leftjoin('stock_mvt_reason_lang', 'smrl', 'smr.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang='.(int)$id_lang);
|
||||
$query->where('smr.deleted = 0');
|
||||
|
||||
if ($sign != null)
|
||||
@@ -120,7 +120,7 @@ class StockMvtReasonCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('smr.id_stock_mvt_reason');
|
||||
$query->from('stock_mvt_reason smr');
|
||||
$query->from('stock_mvt_reason', 'smr');
|
||||
$query->where('smr.id_stock_mvt_reason = '.(int)$id_stock_mvt_reason);
|
||||
$query->where('smr.deleted = 0');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
|
||||
@@ -239,15 +239,15 @@ class SupplyOrderCore extends ObjectModel
|
||||
p.reference as reference,
|
||||
p.ean13 as ean13');
|
||||
|
||||
$query->from('supply_order_detail s');
|
||||
$query->from('supply_order_detail', 's');
|
||||
|
||||
$query->innerjoin('product_lang pl ON (pl.id_product = s.id_product AND pl.id_lang = '.$id_lang.')');
|
||||
$query->innerjoin('product_lang', 'pl', 'pl.id_product = s.id_product AND pl.id_lang = '.$id_lang);
|
||||
|
||||
$query->leftjoin('product p ON p.id_product = s.id_product');
|
||||
$query->leftjoin('product_attribute_combination pac ON (pac.id_product_attribute = s.id_product_attribute)');
|
||||
$query->leftjoin('attribute atr ON (atr.id_attribute = pac.id_attribute)');
|
||||
$query->leftjoin('attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$id_lang.')');
|
||||
$query->leftjoin('attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$id_lang.')');
|
||||
$query->leftjoin('product', 'p', 'p.id_product = s.id_product');
|
||||
$query->leftjoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = s.id_product_attribute');
|
||||
$query->leftjoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
|
||||
$query->leftjoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.$id_lang);
|
||||
$query->leftjoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$id_lang);
|
||||
|
||||
$query->where('s.id_supply_order = '.(int)$this->id);
|
||||
|
||||
@@ -278,7 +278,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('COUNT(*)');
|
||||
$query->from('supply_order_detail s');
|
||||
$query->from('supply_order_detail', 's');
|
||||
$query->where('s.id_supply_order = '.(int)$this->id);
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) > 0);
|
||||
@@ -294,7 +294,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.editable');
|
||||
$query->from('supply_order_state s');
|
||||
$query->from('supply_order_state', 's');
|
||||
$query->where('s.id_supply_order_state = '.(int)$this->id_supply_order_state);
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 1);
|
||||
@@ -310,7 +310,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.delivery_note');
|
||||
$query->from('supply_order_state s');
|
||||
$query->from('supply_order_state', 's');
|
||||
$query->where('s.id_supply_order_state = '.(int)$this->id_supply_order_state);
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 1);
|
||||
@@ -326,7 +326,7 @@ class SupplyOrderCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.receipt_state');
|
||||
$query->from('supply_order_state s');
|
||||
$query->from('supply_order_state', 's');
|
||||
$query->where('s.id_supply_order_state = '.(int)$this->id_supply_order_state);
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 1);
|
||||
@@ -372,8 +372,8 @@ class SupplyOrderCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('COUNT(so.id_supply_order) as supply_orders');
|
||||
$query->from('supply_order so');
|
||||
$query->leftJoin('supply_order_state sos ON (so.id_supply_order_state = sos.id_supply_order_state)');
|
||||
$query->from('supply_order', 'so');
|
||||
$query->leftJoin('supply_order_state', 'sos', 'so.id_supply_order_state = sos.id_supply_order_state');
|
||||
$query->where('sos.enclosed != 1');
|
||||
$query->where('so.id_warehouse = '.(int)$id_warehouse);
|
||||
|
||||
@@ -394,8 +394,8 @@ class SupplyOrderCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('COUNT(so.id_supply_order) as supply_orders');
|
||||
$query->from('supply_order so');
|
||||
$query->leftJoin('supply_order_state sos ON (so.id_supply_order_state = sos.id_supply_order_state)');
|
||||
$query->from('supply_order', 'so');
|
||||
$query->leftJoin('supply_order_state', 'sos', 'so.id_supply_order_state = sos.id_supply_order_state');
|
||||
$query->where('sos.enclosed != 1');
|
||||
$query->where('so.id_supplier = '.(int)$id_supplier);
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ class SupplyOrderStateCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('sl.name, s.id_supply_order_state');
|
||||
$query->from('supply_order_state s');
|
||||
$query->leftjoin('supply_order_state_lang sl ON (s.id_supply_order_state = sl.id_supply_order_state AND sl.id_lang='.(int)$id_lang.')');
|
||||
$query->from('supply_order_state', 's');
|
||||
$query->leftjoin('supply_order_state_lang', 'sl', 's.id_supply_order_state = sl.id_supply_order_state AND sl.id_lang='.(int)$id_lang);
|
||||
|
||||
if (!is_null($id_state_referrer))
|
||||
{
|
||||
|
||||
+13
-13
@@ -85,8 +85,8 @@ class WarehouseCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('ws.id_shop, s.name');
|
||||
$query->from('warehouse_shop ws');
|
||||
$query->leftJoin('shop s ON (s.id_shop = ws.id_shop)');
|
||||
$query->from('warehouse_shop', 'ws');
|
||||
$query->leftJoin('shop', 's', 's.id_shop = ws.id_shop');
|
||||
$query->where($this->def['primary'].' = '.(int)$this->id);
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
@@ -122,7 +122,7 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('wc.id_carrier');
|
||||
$query->from('warehouse_carrier wc');
|
||||
$query->from('warehouse_carrier', 'wc');
|
||||
$query->where($this->def['primary'].' = '.(int)$this->id);
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
@@ -176,7 +176,7 @@ class WarehouseCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(s.physical_quantity)');
|
||||
$query->from('stock s');
|
||||
$query->from('stock', 's');
|
||||
$query->where($this->def['primary'].' = '.(int)$this->id);
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 0);
|
||||
}
|
||||
@@ -259,9 +259,9 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('wpl.id_warehouse, CONCAT(w.reference, " - ", w.name) as name');
|
||||
$query->from('warehouse_product_location wpl');
|
||||
$query->innerJoin('warehouse_shop ws ON (ws.id_warehouse = wpl.id_warehouse AND id_shop = '.(int)$id_shop.')');
|
||||
$query->innerJoin('warehouse w ON (ws.id_warehouse = w.id_warehouse)');
|
||||
$query->from('warehouse_product_location', 'wpl');
|
||||
$query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = wpl.id_warehouse AND id_shop = '.(int)$id_shop);
|
||||
$query->innerJoin('warehouse', 'w', 'ws.id_warehouse = w.id_warehouse');
|
||||
$query->where('id_product = '.(int)$id_product);
|
||||
$query->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
$query->groupBy('wpl.id_warehouse');
|
||||
@@ -285,11 +285,11 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name');
|
||||
$query->from('warehouse w');
|
||||
$query->from('warehouse', 'w');
|
||||
$query->where('deleted = 0');
|
||||
$query->orderBy('reference ASC');
|
||||
if (!$ignore_shop)
|
||||
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.(int)$id_shop);
|
||||
$query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.(int)$id_shop);
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ class WarehouseCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(s.`price_te`)');
|
||||
$query->from('stock s');
|
||||
$query->from('stock', 's');
|
||||
$query->where('s.`id_warehouse` = '.(int)$this->id);
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
@@ -376,7 +376,7 @@ class WarehouseCore extends ObjectModel
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('w.id_warehouse');
|
||||
$query->from('warehouse w');
|
||||
$query->from('warehouse', 'w');
|
||||
$query->where('w.id_employee = '.(int)$id_employee);
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
@@ -396,8 +396,8 @@ class WarehouseCore extends ObjectModel
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('DISTINCT w.id_warehouse, CONCAT(w.reference, " - ", w.name) as name');
|
||||
$query->from('warehouse w');
|
||||
$query->leftJoin('stock s ON (s.id_warehouse = w.id_warehouse)');
|
||||
$query->from('warehouse', 'w');
|
||||
$query->leftJoin('stock', 's', 's.id_warehouse = w.id_warehouse');
|
||||
if ($id_product)
|
||||
$query->where('s.id_product = '.(int)$id_product);
|
||||
if ($id_product_attribute)
|
||||
|
||||
@@ -76,7 +76,7 @@ class WarehouseProductLocationCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('wpl.location');
|
||||
$query->from('warehouse_product_location wpl');
|
||||
$query->from('warehouse_product_location', 'wpl');
|
||||
$query->where('wpl.id_product = '.(int)$id_product.'
|
||||
AND wpl.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND wpl.id_warehouse = '.(int)$id_warehouse
|
||||
@@ -98,7 +98,7 @@ class WarehouseProductLocationCore extends ObjectModel
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('wpl.id_warehouse_product_location');
|
||||
$query->from('warehouse_product_location wpl');
|
||||
$query->from('warehouse_product_location', 'wpl');
|
||||
$query->where('wpl.id_product = '.(int)$id_product.'
|
||||
AND wpl.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND wpl.id_warehouse = '.(int)$id_warehouse
|
||||
|
||||
+2
-2
@@ -148,13 +148,13 @@ class TaxCore extends ObjectModel
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->select('t.id_tax, t.rate');
|
||||
$sql->from('tax t');
|
||||
$sql->from('tax', 't');
|
||||
$sql->where('t.`deleted` != 1');
|
||||
|
||||
if ($id_lang)
|
||||
{
|
||||
$sql->select('tl.name, tl.id_lang');
|
||||
$sql->leftJoin('tax_lang tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')');
|
||||
$sql->leftJoin('tax_lang', 'tl', 't.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang);
|
||||
$sql->orderBy('`name` ASC');
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
$query = new DbQuery();
|
||||
$query->select('pa.id_product_attribute as id, pa.id_product, stock_view.reference, stock_view.ean13,
|
||||
stock_view.upc, stock_view.usable_quantity as stock');
|
||||
$query->from('product_attribute pa');
|
||||
$query->from('product_attribute', 'pa');
|
||||
$query->join('INNER JOIN
|
||||
(
|
||||
SELECT SUM(s.usable_quantity) as usable_quantity, s.id_product_attribute, s.reference, s.ean13, s.upc
|
||||
@@ -319,10 +319,10 @@ class AdminStockCoverControllerCore extends AdminController
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(od.product_quantity)');
|
||||
$query->from('order_detail od');
|
||||
$query->leftJoin('orders o ON (od.id_order = o.id_order)');
|
||||
$query->leftJoin('order_history oh ON (o.date_upd = oh.date_add)');
|
||||
$query->leftJoin('order_state os ON (os.id_order_state = oh.id_order_state)');
|
||||
$query->from('order_detail', 'od');
|
||||
$query->leftJoin('orders', 'o', 'od.id_order = o.id_order');
|
||||
$query->leftJoin('order_history', 'oh', 'o.date_upd = oh.date_add');
|
||||
$query->leftJoin('order_state', 'os', 'os.id_order_state = oh.id_order_state');
|
||||
$query->where('od.product_id = '.(int)$id_product);
|
||||
$query->where('od.product_attribute_id = '.(int)$id_product_attribute);
|
||||
$query->where('TO_DAYS(NOW()) - TO_DAYS(oh.date_add) <= '.(int)$coverage);
|
||||
|
||||
@@ -260,8 +260,8 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
$query = new DbQuery();
|
||||
$query->select('w.id_currency, s.price_te, SUM(s.physical_quantity) as physical_quantity, SUM(s.usable_quantity) as usable_quantity,
|
||||
(s.price_te * SUM(s.physical_quantity)) as valuation');
|
||||
$query->from('stock s');
|
||||
$query->leftJoin('warehouse w ON (w.id_warehouse = s.id_warehouse)');
|
||||
$query->from('stock', 's');
|
||||
$query->leftJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
|
||||
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
|
||||
if ($id_warehouse != -1)
|
||||
$query->where('s.id_warehouse = '.(int)$id_warehouse);
|
||||
@@ -369,8 +369,8 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
// gets prices
|
||||
$query = new DbQuery();
|
||||
$query->select('s.price_te, SUM(s.physical_quantity) as physical_quantity, SUM(s.usable_quantity) as usable_quantity');
|
||||
$query->from('stock s');
|
||||
$query->leftJoin('warehouse w ON (w.id_warehouse = s.id_warehouse)');
|
||||
$query->from('stock', 's');
|
||||
$query->leftJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
|
||||
$query->where('s.id_product = '.$id_product.' AND s.id_product_attribute = '.$id_product_attribute);
|
||||
$query->where('s.id_warehouse = '.$id_warehouse);
|
||||
$query->groupBy('s.price_te');
|
||||
|
||||
@@ -936,7 +936,7 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
$query = new DbQuery();
|
||||
|
||||
$query->select('IFNULL(CONCAT(pl.`name`, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.`name` SEPARATOR \', \')),pl.`name`) as name');
|
||||
$query->from('product_attribute a');
|
||||
$query->from('product_attribute', 'a');
|
||||
$query->join('INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.`id_product_attribute` = a.`id_product_attribute`)
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.`id_attribute` = pac.`id_attribute`)
|
||||
|
||||
@@ -1126,8 +1126,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select(implode(', sod.', $keys));
|
||||
$query->from('supply_order_detail sod');
|
||||
$query->leftJoin('supply_order so ON (so.id_supply_order = sod.id_supply_order)');
|
||||
$query->from('supply_order_detail', 'sod');
|
||||
$query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
|
||||
$id_warehouse = $this->getCurrentWarehouse();
|
||||
if ($id_warehouse != -1)
|
||||
$query->where('so.id_warehouse = '.(int)$id_warehouse);
|
||||
@@ -1498,14 +1498,14 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name
|
||||
');
|
||||
|
||||
$query->from('product p');
|
||||
$query->from('product', 'p');
|
||||
|
||||
$query->innerJoin('product_lang pl ON (pl.id_product = p.id_product AND pl.id_lang = '.$id_lang.')');
|
||||
$query->leftJoin('product_attribute pa ON (pa.id_product = p.id_product)');
|
||||
$query->leftJoin('product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)');
|
||||
$query->leftJoin('attribute atr ON (atr.id_attribute = pac.id_attribute)');
|
||||
$query->leftJoin('attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$id_lang.')');
|
||||
$query->leftJoin('attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$id_lang.')');
|
||||
$query->innerJoin('product_lang', 'pl', 'pl.id_product = p.id_product AND pl.id_lang = '.$id_lang);
|
||||
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product');
|
||||
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
|
||||
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
|
||||
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.$id_lang);
|
||||
$query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$id_lang);
|
||||
|
||||
$query->where('pl.name LIKE \'%'.$pattern.'%\' OR p.reference LIKE \'%'.$pattern.'%\'');
|
||||
$query->where('p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))');
|
||||
@@ -1859,28 +1859,21 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
|
||||
IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
|
||||
IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc');
|
||||
$query->from('product_supplier ps');
|
||||
$query->leftJoin('stock s ON
|
||||
(
|
||||
s.id_product = ps.id_product
|
||||
AND
|
||||
s.id_product_attribute = ps.id_product_attribute
|
||||
)');
|
||||
$query->innerJoin('warehouse_product_location wpl ON
|
||||
(
|
||||
wpl.id_product = ps.id_product
|
||||
AND
|
||||
wpl.id_product_attribute = ps.id_product_attribute
|
||||
AND
|
||||
wpl.id_warehouse = '.(int)$supply_order->id_warehouse.'
|
||||
)');
|
||||
$query->leftJoin('product p ON (p.id_product = ps.id_product)');
|
||||
$query->leftJoin('product_attribute pa ON
|
||||
(
|
||||
pa.id_product_attribute = ps.id_product_attribute
|
||||
AND
|
||||
p.id_product = ps.id_product
|
||||
)');
|
||||
$query->from('product_supplier', 'ps');
|
||||
$query->leftJoin('stock', 's', '
|
||||
s.id_product = ps.id_product
|
||||
AND s.id_product_attribute = ps.id_product_attribute
|
||||
');
|
||||
$query->innerJoin('warehouse_product_location', 'wpl', '
|
||||
wpl.id_product = ps.id_product
|
||||
AND wpl.id_product_attribute = ps.id_product_attribute
|
||||
AND wpl.id_warehouse = '.(int)$supply_order->id_warehouse.'
|
||||
');
|
||||
$query->leftJoin('product', 'p', 'p.id_product = ps.id_product');
|
||||
$query->leftJoin('product_attribute', 'pa', '
|
||||
pa.id_product_attribute = ps.id_product_attribute
|
||||
AND p.id_product = ps.id_product
|
||||
');
|
||||
$query->where('ps.id_supplier = '.(int)$supply_order->id_supplier);
|
||||
|
||||
// gets items
|
||||
|
||||
@@ -829,11 +829,11 @@ class InstallXmlLoader
|
||||
// Build query
|
||||
$sql = new DbQuery();
|
||||
$sql->select('a.*');
|
||||
$sql->from($entity.' a');
|
||||
$sql->from($entity, 'a');
|
||||
if ($is_multilang)
|
||||
{
|
||||
$sql->select('b.*');
|
||||
$sql->leftJoin($entity.'_lang b ON a.'.$primary.' = b.'.$primary);
|
||||
$sql->leftJoin($entity.'_lang', 'b', 'a.'.$primary.' = b.'.$primary);
|
||||
}
|
||||
|
||||
if (isset($config['sql']) && $config['sql'])
|
||||
|
||||
@@ -130,7 +130,7 @@ class Newsletter extends Module
|
||||
{
|
||||
$dbquery = new DbQuery();
|
||||
$dbquery->select('c.`id_customer`, c.`lastname`, c.`firstname`, c.`email`, c.`ip_registration_newsletter`, c.`newsletter_date_add`')
|
||||
->from('customer c')
|
||||
->from('customer', 'c')
|
||||
->groupBy('c.`email`');
|
||||
|
||||
if (Tools::getValue('SUSCRIBERS'))
|
||||
|
||||
Reference in New Issue
Block a user