// Stock : product can now be returned

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11091 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
bMancone
2011-12-09 16:08:27 +00:00
parent f76baf34e6
commit 0ea53c672f
3 changed files with 60 additions and 26 deletions
+21
View File
@@ -189,4 +189,25 @@ class ProductSupplierCore extends ObjectModel
return $res;
}
/**
* For a given Supplier, Product, returns the purchased price
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @return Array keys: price_te, id_currency
*/
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0)
{
if (is_null($id_supplier) || is_null($id_product))
return;
$query = new DbQuery();
$query->select('product_supplier_price_te as price_te, id_currency');
$query->from('product_supplier');
$query->where('id_product = '.(int)$id_product.' AND id_product_attribute = '.(int)$id_product_attribute);
$query->where('id_supplier = '.(int)$id_supplier);
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
}
}
+4 -2
View File
@@ -455,13 +455,15 @@ class StockManagerCore implements StockManagerInterface
// Gets client_orders_qty
$query = new DbQuery();
$query->select('SUM(od.product_quantity)');
$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->where('od.product_id = '.(int)$id_product);
if (0 != $id_product_attribute)
$query->where('od.product_attribute_id = '.(int)$id_product_attribute);
$query->where('o.delivery_number = 0');
$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->where('os.shipped != 1');
$query->where('o.valid = 1');
// @FIXME: Once part-shipping is done, remove the comment on the line below.
// $query->where('o.id_warehouse IN (0, '.implode(', ', $ids_warehouse).')');