// stock : debug + interfaces optimizations + stockManager update

This commit is contained in:
dSevere
2011-11-10 17:30:16 +00:00
parent cb86145611
commit a2c3001445
17 changed files with 540 additions and 379 deletions
+30 -19
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -29,13 +29,13 @@ class OrderHistoryCore extends ObjectModel
{
/** @var integer Order id */
public $id_order;
/** @var integer Order state id */
public $id_order_state;
/** @var integer Employee id for this history entry */
public $id_employee;
/** @var string Object creation date */
public $date_add;
@@ -43,13 +43,13 @@ class OrderHistoryCore extends ObjectModel
public $date_upd;
protected $tables = array ('order_history');
protected $fieldsRequired = array('id_order', 'id_order_state');
protected $fieldsValidate = array('id_order' => 'isUnsignedId', 'id_order_state' => 'isUnsignedId', 'id_employee' => 'isUnsignedId');
protected $table = 'order_history';
protected $identifier = 'id_order_history';
protected $webserviceParameters = array(
'objectsNodeName' => 'order_histories',
'fields' => array(
@@ -61,12 +61,12 @@ class OrderHistoryCore extends ObjectModel
public function getFields()
{
$this->validateFields();
$fields['id_order'] = (int)$this->id_order;
$fields['id_order_state'] = (int)$this->id_order_state;
$fields['id_employee'] = (int)$this->id_employee;
$fields['date_add'] = pSQL($this->date_add);
return $fields;
}
@@ -76,7 +76,7 @@ class OrderHistoryCore extends ObjectModel
{
Hook::updateOrderStatus((int)($new_order_state), (int)$id_order);
$order = new Order((int)($id_order));
/* Best sellers */
$newOS = new OrderState((int)($new_order_state), $order->id_lang);
$oldOrderStatus = OrderHistory::getLastOrderState((int)$id_order);
@@ -91,20 +91,31 @@ class OrderHistoryCore extends ObjectModel
/* If becoming unlogable => removing sale */
elseif (!$newOS->logable AND ($oldOrderStatus AND $oldOrderStatus->logable))
ProductSale::removeProductSale($product['id_product'], $product['cart_quantity']);
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && !$isValidated AND $newOS->logable AND isset($oldOrderStatus) AND $oldOrderStatus AND $oldOrderStatus->id == Configuration::get('PS_OS_ERROR'))
StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], (int)$product['cart_quantity']);
else if ($newOS->shipped == 1 && $oldOrderStatus->shipped == 0) // The product is removed from the physical stock. $id_warehouse is needed
Stock::updateQuantity($product['id_product'], $product['id_product_attribute'], -$product['cart_quantity'], $id_warehouse, $id_order);
{
$manager = StockManagerFactory::getManager();
$warehouse = new Warehouse($id_warehouse);
$manager->removeProduct($product['id_product'],
$product['id_product_attribute'],
$warehouse,
$product['cart_quantity'],
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
true,
(int)$id_order);
}
// @todo If the old order states was "shipped" and the new is "not shipped" the stock is not decremented
}
$this->id_order_state = (int)($new_order_state);
/* Change invoice number of order ? */
if (!Validate::isLoadedObject($newOS) OR !Validate::isLoadedObject($order))
die(Tools::displayError('Invalid new order state'));
/* The order is valid only if the invoice is available and the order is not cancelled */
$order->valid = $newOS->logable;
$order->update();
@@ -134,7 +145,7 @@ class OrderHistoryCore extends ObjectModel
if (!$context)
$context = Context::getContext();
$lastOrderState = $this->getLastOrderState($this->id_order);
if (!parent::add($autodate))
return false;
@@ -156,7 +167,7 @@ class OrderHistoryCore extends ObjectModel
$order = new Order((int)$this->id_order);
$data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);
$data['{order_name}'] = sprintf("#%06d", (int)$order->id);
// An additional email is sent the first time a virtual item is validated
if ($virtualProducts = $order->getVirtualProducts() AND (!$lastOrderState OR !$lastOrderState->logable) AND $newOrderState = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT')) AND $newOrderState->logable)
{
@@ -196,13 +207,13 @@ class OrderHistoryCore extends ObjectModel
return true;
}
public function isValidated()
{
return Db::getInstance()->getValue('
SELECT COUNT(oh.`id_order_history`) AS nb
FROM `'._DB_PREFIX_.'order_state` os
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (os.`id_order_state` = oh.`id_order_state`)
FROM `'._DB_PREFIX_.'order_state` os
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (os.`id_order_state` = oh.`id_order_state`)
WHERE oh.`id_order` = '.(int)$this->id_order.'
AND os.`logable` = 1');
}
+2
View File
@@ -378,6 +378,8 @@ class ToolsCore
*/
public static function displayPrice($price, $currency = NULL, $no_utf8 = false, Context $context = null)
{
if (!is_numeric($price))
return $price;
if (!$context)
$context = Context::getContext();
if ($currency === NULL)
-30
View File
@@ -73,34 +73,4 @@ class StockCore extends ObjectModel
$fields['price_te'] = (float)round($this->price_te, 6);
return $fields;
}
/**
* For a given id_product and id_product_attribute update the quantity in stock
*/
public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_warehouse, $id_order = null)
{
$warehouse = new Warehouse($id_warehouse);
// Update quantity of the pack products
if (Pack::isPack($id_product))
{
$products_pack = Pack::getItems((int)$product['id_product'], (int)Configuration::get('PS_LANG_DEFAULT'));
foreach ($products_pack as $product_pack)
{
$pack_id_product_attribute = Product::getDefaultAttribute($tab_product_pack['id_product'], 1);
self::updateQuantity($product_pack->id, $pack_id_product_attribute, $product_pack->pack_quantity * $delta_quantity, $id_warehouse, $id_order);
}
}
if ($delta_quantity > 0)
$id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_INC_REASON_DEFAULT');
else
$id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_DEC_REASON_DEFAULT');
StockManagerFactory::getManager()->removeProduct($id_product,
$id_product_attribute,
$warehouse,
$delta_quantity,
$id_stock_mvt_reason,
true,
(int)$id_order);
}
}
+171 -157
View File
@@ -202,188 +202,202 @@ class StockManagerCore implements StockManagerInterface
$context = Context::getContext();
// gets total quantities in stock for the current product
$physical_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), false);
$usable_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), true);
// check quantity if we want to decrement unusable quantity
if (!$is_usable)
$quantity_in_stock = $physical_quantity_in_stock - $usable_quantity_in_stock;
else
$quantity_in_stock = $usable_quantity_in_stock;
// checks if it's possible to remove the given quantity
if ($quantity_in_stock < $quantity)
return $return;
$stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
// check if the collection is loaded
if (count($stock_collection) <= 0)
return $return;
$stock_history_qty_available = array();
$mvt_params = array();
$stock_params = array();
$quantity_to_decrement_by_stock = array();
$global_quantity_to_decrement = $quantity;
// switch on MANAGEMENT_TYPE
switch ($warehouse->management_type)
// Special case of a pack
if (Pack::isPack($id_product))
{
// case CUMP mode
case 'WA':
// There is one and only one stock for a given product in a warehouse in this mode
$stock = $stock_collection[0];
$products_pack = Pack::getItems((int)$product['id_product'], (int)Configuration::get('PS_LANG_DEFAULT'));
foreach ($products_pack as $product_pack)
{
$pack_id_product_attribute = Product::getDefaultAttribute($tab_product_pack['id_product'], 1); //@TODO is there a better way to retrieve the product attribute assciated to the pack ?
$this->removeProduct($product_pack->id, $pack_id_product_attribute, $product_pack->pack_quantity * $quantity, $warehouse, $id_order);
}
}
else
{
// gets total quantities in stock for the current product
$physical_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), false);
$usable_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), true);
$mvt_params = array(
'id_stock' => $stock->id,
'physical_quantity' => $quantity,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
'id_order' => $id_order,
'price_te' => $stock->price_te,
'last_wa' => $stock->price_te,
'current_wa' => $stock->price_te,
'id_employee' => $context->employee->id,
'sign' => -1
);
$stock_params = array(
'physical_quantity' => ($stock->physical_quantity - $quantity),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity)
);
// check quantity if we want to decrement unusable quantity
if (!$is_usable)
$quantity_in_stock = $physical_quantity_in_stock - $usable_quantity_in_stock;
else
$quantity_in_stock = $usable_quantity_in_stock;
// saves stock in warehouse
$stock->hydrate($stock_params);
$stock->update();
// checks if it's possible to remove the given quantity
if ($quantity_in_stock < $quantity)
return $return;
// saves stock mvt
$stock_mvt = new StockMvt();
$stock_mvt->hydrate($mvt_params);
$stock_mvt->save();
$stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
$return[$stock->id]['quantity'] = $quantity;
$return[$stock->id]['price_te'] = $stock->price_te;
// check if the collection is loaded
if (count($stock_collection) <= 0)
return $return;
break;
$stock_history_qty_available = array();
$mvt_params = array();
$stock_params = array();
$quantity_to_decrement_by_stock = array();
$global_quantity_to_decrement = $quantity;
case 'LIFO':
case 'FIFO':
// switch on MANAGEMENT_TYPE
switch ($warehouse->management_type)
{
// case CUMP mode
case 'WA':
// There is one and only one stock for a given product in a warehouse in this mode
$stock = $stock_collection[0];
// for each stock, parse its mvts history to calculate the quantities left for each positive mvt,
// according to the instant available quantities for this stock
foreach ($stock_collection as $stock)
{
$left_quantity_to_check = $stock->physical_quantity;
if ($left_quantity_to_check <= 0)
continue;
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`,
IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty
FROM `'._DB_PREFIX_.'stock_mvt` sm
LEFT JOIN `'._DB_PREFIX_.'stock_mvt` sm2 ON sm2.`referer` = sm.`id_stock_mvt`
WHERE sm.`sign` = 1
AND sm.`id_stock` = '.(int)$stock->id.'
GROUP BY sm.`id_stock_mvt`
ORDER BY sm.`date_add` DESC'
$mvt_params = array(
'id_stock' => $stock->id,
'physical_quantity' => $quantity,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
'id_order' => $id_order,
'price_te' => $stock->price_te,
'last_wa' => $stock->price_te,
'current_wa' => $stock->price_te,
'id_employee' => $context->employee->id,
'sign' => -1
);
$stock_params = array(
'physical_quantity' => ($stock->physical_quantity - $quantity),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity)
);
while ($row = Db::getInstance()->nextRow($resource))
// saves stock in warehouse
$stock->hydrate($stock_params);
$stock->update();
// saves stock mvt
$stock_mvt = new StockMvt();
$stock_mvt->hydrate($mvt_params);
$stock_mvt->save();
$return[$stock->id]['quantity'] = $quantity;
$return[$stock->id]['price_te'] = $stock->price_te;
break;
case 'LIFO':
case 'FIFO':
// for each stock, parse its mvts history to calculate the quantities left for each positive mvt,
// according to the instant available quantities for this stock
foreach ($stock_collection as $stock)
{
// break - in FIFO mode, we have to retreive the oldest positive mvts for which there are left quantities
if ($warehouse->management_type == 'FIFO')
if ($row['qty'] == 0)
break;
$left_quantity_to_check = $stock->physical_quantity;
if ($left_quantity_to_check <= 0)
continue;
// converts date to timestamp
$date = new DateTime($row['date_add']);
$timestamp = $date->format('U');
// history of the mvt
$stock_history_qty_available[$timestamp] = array(
'id_stock' => $stock->id,
'id_stock_mvt' => (int)$row['id_stock_mvt'],
'qty' => (int)$row['qty']
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`,
IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty
FROM `'._DB_PREFIX_.'stock_mvt` sm
LEFT JOIN `'._DB_PREFIX_.'stock_mvt` sm2 ON sm2.`referer` = sm.`id_stock_mvt`
WHERE sm.`sign` = 1
AND sm.`id_stock` = '.(int)$stock->id.'
GROUP BY sm.`id_stock_mvt`
ORDER BY sm.`date_add` DESC'
);
// break - in LIFO mode, checks only the necessary history to handle the global quantity for the current stock
if ($warehouse->management_type == 'LIFO')
while ($row = Db::getInstance()->nextRow($resource))
{
$left_quantity_to_check -= (int)$row['physical_quantity'];
if ($left_quantity_to_check <= 0)
break;
}
}
}
// break - in FIFO mode, we have to retreive the oldest positive mvts for which there are left quantities
if ($warehouse->management_type == 'FIFO')
if ($row['qty'] == 0)
break;
if ($warehouse->management_type == 'LIFO')
// orders stock history by timestamp to get newest history first
krsort($stock_history_qty_available);
else
// orders stock history by timestamp to get oldest history first
ksort($stock_history_qty_available);
// converts date to timestamp
$date = new DateTime($row['date_add']);
$timestamp = $date->format('U');
// checks each stock to manage the real quantity to decrement for each of them
foreach ($stock_history_qty_available as $entry)
{
if ($entry['qty'] >= $global_quantity_to_decrement)
{
$quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $global_quantity_to_decrement;
$global_quantity_to_decrement = 0;
}
else
{
$quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $entry['qty'];
$global_quantity_to_decrement -= $entry['qty'];
}
if ($global_quantity_to_decrement <= 0)
break;
}
// for each stock, decrements it and logs the mvts
foreach ($stock_collection as $stock)
{
if (array_key_exists($stock->id, $quantity_to_decrement_by_stock) && is_array($quantity_to_decrement_by_stock[$stock->id]))
{
$total_quantity_for_current_stock = 0;
foreach ($quantity_to_decrement_by_stock[$stock->id] as $id_mvt_referrer => $qte)
{
$mvt_params = array(
// history of the mvt
$stock_history_qty_available[$timestamp] = array(
'id_stock' => $stock->id,
'physical_quantity' => $qte,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
'id_order' => $id_order,
'price_te' => $stock->price_te,
'sign' => -1,
'referer' => $id_mvt_referrer,
'id_employee' => $context->employee->id
'id_stock_mvt' => (int)$row['id_stock_mvt'],
'qty' => (int)$row['qty']
);
// saves stock mvt
$stock_mvt = new StockMvt();
$stock_mvt->hydrate($mvt_params);
$stock_mvt->save();
// break - in LIFO mode, checks only the necessary history to handle the global quantity for the current stock
if ($warehouse->management_type == 'LIFO')
{
$left_quantity_to_check -= (int)$row['physical_quantity'];
if ($left_quantity_to_check <= 0)
break;
}
}
}
$total_quantity_for_current_stock += $qte;
if ($warehouse->management_type == 'LIFO')
// orders stock history by timestamp to get newest history first
krsort($stock_history_qty_available);
else
// orders stock history by timestamp to get oldest history first
ksort($stock_history_qty_available);
// checks each stock to manage the real quantity to decrement for each of them
foreach ($stock_history_qty_available as $entry)
{
if ($entry['qty'] >= $global_quantity_to_decrement)
{
$quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $global_quantity_to_decrement;
$global_quantity_to_decrement = 0;
}
else
{
$quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $entry['qty'];
$global_quantity_to_decrement -= $entry['qty'];
}
$stock_params = array(
'physical_quantity' => ($stock->physical_quantity - $total_quantity_for_current_stock),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity)
);
$return[$stock->id]['quantity'] = $total_quantity_for_current_stock;
$return[$stock->id]['price_te'] = $stock->price_te;
// saves stock in warehouse
$stock->hydrate($stock_params);
$stock->update();
if ($global_quantity_to_decrement <= 0)
break;
}
}
break;
// for each stock, decrements it and logs the mvts
foreach ($stock_collection as $stock)
{
if (array_key_exists($stock->id, $quantity_to_decrement_by_stock) && is_array($quantity_to_decrement_by_stock[$stock->id]))
{
$total_quantity_for_current_stock = 0;
foreach ($quantity_to_decrement_by_stock[$stock->id] as $id_mvt_referrer => $qte)
{
$mvt_params = array(
'id_stock' => $stock->id,
'physical_quantity' => $qte,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
'id_order' => $id_order,
'price_te' => $stock->price_te,
'sign' => -1,
'referer' => $id_mvt_referrer,
'id_employee' => $context->employee->id
);
// saves stock mvt
$stock_mvt = new StockMvt();
$stock_mvt->hydrate($mvt_params);
$stock_mvt->save();
$total_quantity_for_current_stock += $qte;
}
$stock_params = array(
'physical_quantity' => ($stock->physical_quantity - $total_quantity_for_current_stock),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity)
);
$return[$stock->id]['quantity'] = $total_quantity_for_current_stock;
$return[$stock->id]['price_te'] = $stock->price_te;
// saves stock in warehouse
$stock->hydrate($stock_params);
$stock->update();
}
}
break;
}
}
return $return;
}
+12 -5
View File
@@ -33,28 +33,35 @@ class StockMvtCore extends ObjectModel
/**
* @since 1.5.0
* @var int
* @var int The stock id on wtich the movement is applied
*/
public $id_stock;
/**
* @since 1.5.0
* @var int
* @var int the quantity of product with is moved
*/
public $physical_quantity;
/**
* @var int id of the movement reason assoiated to the movement
*/
public $id_stock_mvt_reason;
/**
* @var int Used when the movement is due to a customer order
*/
public $id_order = null;
/**
* @since 1.5.0
* @var int
* @var int detrmine if the movement is a positive or negative operation
*/
public $sign;
/**
* @since 1.5.0
* @var int Will be used when supplier order are implemented
* @var int Used when the movement is due to a supplier order
*/
public $id_supplier_order = null;
@@ -72,7 +79,7 @@ class StockMvtCore extends ObjectModel
/**
* @since 1.5.0
* @var float
* @var float The unit price without tax of the product associated to the movement
*/
public $price_te;
+17 -1
View File
@@ -27,14 +27,26 @@
class StockMvtReasonCore extends ObjectModel
{
/** @var int identifier of the movement reason */
public $id;
/** @var string the name of the movement reason */
public $name;
/** @var int detrmine if the movement reason correspond to a positive or negative operation */
public $sign;
/** @var string the creation date of the movement reason */
public $date_add;
/** @var string the last update date of the movement reason */
public $date_upd;
/** @var boolean True if the movement reason has been deleted (staying in database as deleted) */
public $deleted = 0;
protected $table = 'stock_mvt_reason';
protected $identifier = 'id_stock_mvt_reason';
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 255);
protected $fieldsValidateLang = array('name' => 'isGenericName');
@@ -50,6 +62,7 @@ class StockMvtReasonCore extends ObjectModel
$fields['sign'] = (int)$this->sign;
$fields['date_add'] = pSQL($this->date_add);
$fields['date_upd'] = pSQL($this->date_upd);
$fields['deleted'] = (int)$this->deleted;
return $fields;
}
@@ -65,6 +78,7 @@ class StockMvtReasonCore extends ObjectModel
$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->where('smr.deleted = 0');
if ($sign != null)
$query->where('smr.sign = '.(int)$sign);
@@ -86,6 +100,7 @@ class StockMvtReasonCore extends ObjectModel
$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->where('smr.deleted = 0');
if ($sign != null)
$query->where('smr.sign = '.(int)$sign);
@@ -111,6 +126,7 @@ class StockMvtReasonCore extends ObjectModel
$query->select('smr.id_stock_mvt_reason');
$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);
}
}
+18
View File
@@ -32,13 +32,27 @@
*/
class WarehouseCore extends ObjectModel
{
/** @var int identifier of the warehouse */
public $id;
/** @var int The id of the address associated to the warehouse */
public $id_address;
/** @var string The reference of the warehouse */
public $reference;
/** @var string The name of the warehouse */
public $name;
/** @var int The id of the employee who is responsible of the warehouse */
public $id_employee;
/** @var int The id of the valuation currency of the warehouse */
public $id_currency;
/** @var boolean True if warehouse has been deleted (staying in database as deleted) */
public $deleted = 0;
/**
* Describes the way a Warehouse is managed
* @var enum WA|LIFO|FIFO
@@ -78,9 +92,11 @@ class WarehouseCore extends ObjectModel
$fields['id_address'] = (int)$this->id_address;
$fields['reference'] = $this->reference;
$fields['name'] = pSQL($this->name);
$fields['deleted'] = (int)$this->deleted;
$fields['id_employee'] = (int)$this->id_employee;
$fields['management_type'] = pSQL($this->management_type);
$fields['id_currency'] = (int)$this->id_currency;
return $fields;
}
@@ -192,6 +208,7 @@ class WarehouseCore extends ObjectModel
$query->select('id_warehouse');
$query->from('warehouse');
$query->where('id_warehouse = '.(int)$id_warehouse);
$query->where('deleted = 0');
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query));
}
@@ -259,6 +276,7 @@ class WarehouseCore extends ObjectModel
$query = new DbQuery();
$query->select('w.id_warehouse, name');
$query->from('warehouse w');
$query->where('deleted = 0');
if (!$ignore_shop)
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.(int)$id_shop);