Skip to content

Commit

Permalink
[-] BO : Fix PSCSX-3368 stock available correct if no combination and…
Browse files Browse the repository at this point in the history
… add one
  • Loading branch information
sfroment committed Sep 19, 2014
1 parent fde688c commit 43e6f3f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion classes/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,6 @@ public function addCombinationEntity($wholesale_price, $price, $weight, $unit_im
$id_product_attribute = $this->addAttribute(
$price, $weight, $unit_impact, $ecotax, $id_images,
$reference, $ean13, $default, $location, $upc, $minimal_quantity, $id_shop_list, $available_date);

$this->addSupplierReference($id_supplier, $id_product_attribute);
$result = ObjectModel::updateMultishopTable('Combination', array(
'wholesale_price' => (float)$wholesale_price,
Expand Down Expand Up @@ -1530,6 +1529,16 @@ public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images,
if (!$combination->id)
return false;

$total_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(quantity) as quantity
FROM '._DB_PREFIX_.'stock_available
WHERE id_product = '.(int)$this->id.'
AND id_product_attribute <> 0 '
);

if (!$total_quantity)
Db ::getInstance()->update('stock_available', array('quantity' => 0), '`id_product` = '.$this->id);

$id_default_attribute = Product::updateDefaultAttribute($this->id);
if ($id_default_attribute)
$this->cache_default_attribute = $id_default_attribute;
Expand Down

0 comments on commit 43e6f3f

Please sign in to comment.