[-] Core: Fix PSCFV-3092

This commit is contained in:
rGaillard
2012-08-03 14:40:31 +00:00
parent 2ad34b2c88
commit ae5acf0be9
4 changed files with 24 additions and 8 deletions
+1 -1
View File
@@ -646,7 +646,7 @@ abstract class PaymentModuleCore extends Module
if (StockAvailable::dependsOnStock($product['product_id']))
{
// synchronizes
StockAvailable::synchronize($product['product_id']);
StockAvailable::synchronize($product['product_id'], $order->id_shop);
}
}
}
+4 -4
View File
@@ -111,11 +111,11 @@ class OrderHistoryCore extends ObjectModel
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) &&
($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) &&
!StockAvailable::dependsOnStock($product['id_product']))
!StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
}
// if becoming unlogable => removes sale
else if (!$new_os->logable && $old_os->logable)
elseif (!$new_os->logable && $old_os->logable)
{
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
@@ -126,7 +126,7 @@ class OrderHistoryCore extends ObjectModel
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
}
// if waiting for payment => payment error/canceled
else if (!$new_os->logable && !$old_os->logable &&
elseif (!$new_os->logable && !$old_os->logable &&
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
!StockAvailable::dependsOnStock($product['id_product']))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
@@ -153,7 +153,7 @@ class OrderHistoryCore extends ObjectModel
);
}
// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
else if ($new_os->shipped == 0 && $old_os->shipped == 1 &&
elseif ($new_os->shipped == 0 && $old_os->shipped == 1 &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
+15 -2
View File
@@ -112,11 +112,18 @@ class StockAvailableCore extends ObjectModel
*
* @param int $id_product
*/
public static function synchronize($id_product)
public static function synchronize($id_product, $order_id_shop = null)
{
// gets warehouse ids grouped by shops
$ids_warehouse = Warehouse::getWarehousesGroupedByShops();
if ($order_id_shop !== null)
{
$order_warehouses = array();
$wh = Warehouse::getWarehouses(false, (int)$order_id_shop);
foreach ($wh as $warehouse)
$order_warehouses[] = $warehouse['id_warehouse'];
}
// gets all product attributes ids
$ids_product_attribute = array();
foreach (Product::getProductAttributesIds($id_product) as $id_product_attribute)
@@ -143,6 +150,9 @@ class StockAvailableCore extends ObjectModel
foreach ($allowed_warehouse_for_product as $warehouse)
$allowed_warehouse_for_product_clean[] = (int)$warehouse['id_warehouse'];
$allowed_warehouse_for_product_clean = array_intersect($allowed_warehouse_for_product_clean, $warehouses);
if ($order_id_shop != null && !count(array_intersect($allowed_warehouse_for_product_clean, $order_warehouses)))
continue;
$product_quantity = $manager->getProductRealQuantities($id_product, null, $allowed_warehouse_for_product_clean, true);
}
// else this product has attributes, hence loops on $ids_product_attribute
@@ -156,6 +166,9 @@ class StockAvailableCore extends ObjectModel
foreach ($allowed_warehouse_for_combination as $warehouse)
$allowed_warehouse_for_combination_clean[] = (int)$warehouse['id_warehouse'];
$allowed_warehouse_for_combination_clean = array_intersect($allowed_warehouse_for_combination_clean, $warehouses);
if ($order_id_shop != null && !count(array_intersect($allowed_warehouse_for_combination_clean, $order_warehouses)))
continue;
$quantity = $manager->getProductRealQuantities($id_product, $id_product_attribute, $allowed_warehouse_for_combination_clean, true);
$query = new DbQuery();
+4 -1
View File
@@ -304,7 +304,10 @@ class WarehouseCore extends ObjectModel
if (Shop::getContext() == Shop::CONTEXT_GROUP)
$shop_group = Shop::getContextShopGroup();
else
{
$shop_group = Context::getContext()->shop->getGroup();
$id_shop = (int)Context::getContext()->shop->id;
}
$share_stock = $shop_group->share_stock;
}
else
@@ -316,7 +319,7 @@ class WarehouseCore extends ObjectModel
if ($share_stock)
$ids_shop = Shop::getShops(true, (int)$shop_group->id, true);
else
$ids_shop = array((int)Context::getContext()->shop->id);
$ids_shop = array((int)$id_shop);
$query = new DbQuery();
$query->select('wpl.id_warehouse, CONCAT(w.reference, " - ", w.name) as name');