[+] BO : Added support to set A warehouse by id
[*] BO : Import will clear any warehouses allready set
This commit is contained in:
1 parent
4857c8c788
commit
909948bfb9
1 file changed
+23
-2
@@ -248,6 +248,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
'label' => $this->l('Advanced Stock Management'),
|
'label' => $this->l('Advanced Stock Management'),
|
||||||
'help' => $this->l('Enable Advanced Stock Management on product (0 = No, 1 = Yes)')
|
'help' => $this->l('Enable Advanced Stock Management on product (0 = No, 1 = Yes)')
|
||||||
),
|
),
|
||||||
|
'warehouse' => array('label' => $this->l('Warehouse')),
|
||||||
);
|
);
|
||||||
|
|
||||||
self::$default_values = array(
|
self::$default_values = array(
|
||||||
@@ -1484,10 +1485,10 @@ class AdminImportControllerCore extends AdminController
|
|||||||
|
|
||||||
// set advanced stock managment
|
// set advanced stock managment
|
||||||
if($product->advanced_stock_management) {
|
if($product->advanced_stock_management) {
|
||||||
if($product->advanced_stock_management != 1 || $product->advanced_stock_management != 0) {
|
if($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) {
|
||||||
$this->warnings[] = Tools::displayError('Advanced stock management has incorrect value. Not set');
|
$this->warnings[] = Tools::displayError('Advanced stock management has incorrect value. Not set');
|
||||||
} elseif(!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) {
|
} elseif(!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) {
|
||||||
$this->warnings[] = Tools::displayError('Advanced stock management is not enabled, can not enable on product ');
|
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, can not enable on product %1$s '),$product->name[$default_language_id]);
|
||||||
} else {
|
} else {
|
||||||
$product->setAdvancedStockManagement($product->advanced_stock_management);
|
$product->setAdvancedStockManagement($product->advanced_stock_management);
|
||||||
}
|
}
|
||||||
@@ -1497,6 +1498,26 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if warehouse exists
|
||||||
|
if(Warehouse::exists($product->warehouse)) {
|
||||||
|
// Get already associated warehouses
|
||||||
|
$associated_warehouses_collection = WarehouseProductLocation::getCollection($product->id);
|
||||||
|
|
||||||
|
// Delete any entry in warehouse for this product
|
||||||
|
foreach ($associated_warehouses_collection as $awc)
|
||||||
|
{
|
||||||
|
$awc->delete();
|
||||||
|
}
|
||||||
|
$warehouse_location_entity = new WarehouseProductLocation();
|
||||||
|
$warehouse_location_entity->id_product = $product->id;
|
||||||
|
$warehouse_location_entity->id_product_attribute = 0;
|
||||||
|
$warehouse_location_entity->id_warehouse = $product->warehouse;
|
||||||
|
$warehouse_location_entity->save();
|
||||||
|
|
||||||
|
StockAvailable::synchronize($product->id); // Don't know if it is needed, but it can't hurt
|
||||||
|
} else {
|
||||||
|
$this->warnings[] = sprintf(Tools::displayError('Warehouse did not exists, can not set on product %1$s '),$product->name[$default_language_id]);
|
||||||
|
}
|
||||||
|
|
||||||
// stock available
|
// stock available
|
||||||
if (Shop::isFeatureActive())
|
if (Shop::isFeatureActive())
|
||||||
|
|||||||
Reference in new issue
Block a user