// normalize

This commit is contained in:
bMancone
2012-03-28 10:07:57 +00:00
parent afad014e5f
commit d2d314665f
2 changed files with 20 additions and 5 deletions
+9 -4
View File
@@ -113,11 +113,12 @@ class StockCore extends ObjectModel
} }
/** /**
* Try to get reference, ean13 and upc information on current product * Gets reference, ean13 and upc of the current product
* and store it in stock for stock_mvt integrity and history use * Stores it in stock for stock_mvt integrity and history purposes
*/ */
protected function getProductInformations() protected function getProductInformations()
{ {
// if combinations
if ((int)$this->id_product_attribute > 0) if ((int)$this->id_product_attribute > 0)
{ {
$query = new DbQuery(); $query = new DbQuery();
@@ -125,15 +126,19 @@ class StockCore extends ObjectModel
$query->from('product_attribute'); $query->from('product_attribute');
$query->where('id_product = '.(int)$this->id_product); $query->where('id_product = '.(int)$this->id_product);
$query->where('id_product_attribute = '.(int)$this->id_product_attribute); $query->where('id_product_attribute = '.(int)$this->id_product_attribute);
$rows = Db::getInstance()->executeS($query);
foreach (Db::getInstance()->executeS($query) as $row) if (!is_array($rows))
return;
foreach ($rows as $row)
{ {
$this->reference = $row['reference']; $this->reference = $row['reference'];
$this->ean13 = $row['ean13']; $this->ean13 = $row['ean13'];
$this->upc = $row['upc']; $this->upc = $row['upc'];
} }
} }
else else // else, simple product
{ {
$product = new Product((int)$this->id_product); $product = new Product((int)$this->id_product);
if (Validate::isLoadedObject($product)) if (Validate::isLoadedObject($product))
+11 -1
View File
@@ -164,10 +164,12 @@ class StockMvtCore extends ObjectModel
/** /**
* @deprecated since 1.5.0 * @deprecated since 1.5.0
* *
* This method no longer exists, and have no equivalent because the missing movements have to be handled by inventories. * This method no longer exists.
* There is no equivalent or replacement, considering that this should be handled by inventories.
*/ */
public static function addMissingMvt($id_employee) public static function addMissingMvt($id_employee)
{ {
// display that this method is deprecated
Tools::displayAsDeprecated(); Tools::displayAsDeprecated();
} }
@@ -188,6 +190,7 @@ class StockMvtCore extends ObjectModel
$movements = array(); $movements = array();
$quantity_total = 0; $quantity_total = 0;
// preps query
$query = new DbQuery(); $query = new DbQuery();
$query->select('sm.*, s.id_warehouse'); $query->select('sm.*, s.id_warehouse');
$query->from('stock_mvt', 'sm'); $query->from('stock_mvt', 'sm');
@@ -195,11 +198,18 @@ class StockMvtCore extends ObjectModel
$query->where('sm.sign = -1'); $query->where('sm.sign = -1');
$query->where('sm.id_order = '.(int)$id_order); $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); $query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
// if filer by warehouse
if (!is_null($id_warehouse)) if (!is_null($id_warehouse))
$query->where('s.id_warehouse = '.(int)$id_warehouse); $query->where('s.id_warehouse = '.(int)$id_warehouse);
// orders the movements by date
$query->orderBy('date_add DESC'); $query->orderBy('date_add DESC');
// gets the result
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($query); $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($query);
// fills the movements array
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($res)) while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($res))
{ {
if ($quantity_total >= $quantity) if ($quantity_total >= $quantity)