Merge branch '1.6' of https://github.com/PrestaShop/PrestaShop into 1.6
This commit is contained in:
@@ -145,7 +145,19 @@ class AdminImportControllerCore extends AdminController
|
||||
'shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
)
|
||||
),
|
||||
'advanced_stock_management' => array(
|
||||
'label' => $this->l('Advanced Stock Management'),
|
||||
'help' => $this->l('Enable Advanced Stock Management on product (0 = No, 1 = Yes)')
|
||||
),
|
||||
'depends_on_stock' => array(
|
||||
'label' => $this->l('Depends On Stock'),
|
||||
'help' => $this->l('0 = Use quantity set in product, 1 = Use quantity from Warehouse')
|
||||
),
|
||||
'warehouse' => array(
|
||||
'label' => $this->l('Warehouse'),
|
||||
'help' => $this->l('ID of the warehouse to set as storeage')
|
||||
),
|
||||
);
|
||||
|
||||
self::$default_values = array(
|
||||
@@ -160,6 +172,8 @@ class AdminImportControllerCore extends AdminController
|
||||
'minimal_quantity' => 1,
|
||||
'weight' => 0,
|
||||
'default_on' => 0,
|
||||
'advanced_stock_management' => 0,
|
||||
'depends_on_stock' => 0,
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -255,11 +269,22 @@ class AdminImportControllerCore extends AdminController
|
||||
'uploadable_files' => array('label' => $this->l('Uploadable files (0 = No, 1 = Yes)')),
|
||||
'text_fields' => array('label' => $this->l('Text fields (0 = No, 1 = Yes)')),
|
||||
'out_of_stock' => array('label' => $this->l('Action when out of stock')),
|
||||
'advanced_stock_management' => array('label' => $this->l('Advanced stock management')),
|
||||
'shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
)
|
||||
),
|
||||
'advanced_stock_management' => array(
|
||||
'label' => $this->l('Advanced Stock Management'),
|
||||
'help' => $this->l('Enable Advanced Stock Management on product (0 = No, 1 = Yes)')
|
||||
),
|
||||
'depends_on_stock' => array(
|
||||
'label' => $this->l('Depends On Stock'),
|
||||
'help' => $this->l('0 = Use quantity set in product, 1 = Use quantity from Warehouse')
|
||||
),
|
||||
'warehouse' => array(
|
||||
'label' => $this->l('Warehouse'),
|
||||
'help' => $this->l('ID of the warehouse to set as storeage')
|
||||
),
|
||||
);
|
||||
|
||||
self::$default_values = array(
|
||||
@@ -287,7 +312,8 @@ class AdminImportControllerCore extends AdminController
|
||||
'uploadable_files' => 0,
|
||||
'text_fields' => 0,
|
||||
'out_of_stock' => '2',
|
||||
'advanced_stock_management' => '0',
|
||||
'advanced_stock_management' => 0,
|
||||
'depends_on_stock' => 0,
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -1694,15 +1720,91 @@ class AdminImportControllerCore extends AdminController
|
||||
Feature::cleanPositions();
|
||||
}
|
||||
|
||||
// stock available
|
||||
if (Shop::isFeatureActive())
|
||||
// set advanced stock managment
|
||||
if (isset($product->advanced_stock_management))
|
||||
{
|
||||
foreach ($shops as $shop)
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, (int)$shop);
|
||||
if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management has incorrect value. Not set for product %1$s '),$product->name[$default_language_id]);
|
||||
elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, can not enable on product %1$s '),$product->name[$default_language_id]);
|
||||
else
|
||||
$product->setAdvancedStockManagement($product->advanced_stock_management);
|
||||
// automaticly disable depends on stock, if a_s_m set to disabled
|
||||
if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0)
|
||||
StockAvailable::setProductDependsOnStock($product->id, 0);
|
||||
}
|
||||
else
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id);
|
||||
|
||||
// Check if warehouse exists
|
||||
if ($product->warehouse)
|
||||
{
|
||||
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, warehouse not set on product %1$s '),$product->name[$default_language_id]);
|
||||
else
|
||||
{
|
||||
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;
|
||||
if (WarehouseProductLocation::getProductLocation($product->id, 0, $product->warehouse) !== false)
|
||||
$warehouse_location_entity->update();
|
||||
else
|
||||
$warehouse_location_entity->save();
|
||||
StockAvailable::synchronize($product->id);
|
||||
}
|
||||
else
|
||||
$this->warnings[] = sprintf(Tools::displayError('Warehouse did not exists, can not set on product %1$s '),$product->name[$default_language_id]);
|
||||
}
|
||||
}
|
||||
|
||||
// stock available
|
||||
if (isset($product->depends_on_stock))
|
||||
{
|
||||
if ($product->depends_on_stock != 0 && $product->depends_on_stock != 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Incorrect value for depends on stock for product %1$s '),$product->name[$default_language_id]);
|
||||
elseif ((!$product->advanced_stock_management || $product->advanced_stock_management == 0) && $product->depends_on_stock == 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management not enabled, can not set depends on stock %1$s '),$product->name[$default_language_id]);
|
||||
else
|
||||
StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock);
|
||||
|
||||
// This code allows us to set qty and disable depends on stock
|
||||
if (isset($product->quantity) && $product->depends_on_stock == 0)
|
||||
{
|
||||
if (Shop::isFeatureActive())
|
||||
foreach ($shops as $shop)
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, (int)$shop);
|
||||
else
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id);
|
||||
}
|
||||
// elseif enable depends on stock and quantity, add quantity to stock
|
||||
elseif (isset($product->quantity) && $product->depends_on_stock == 1)
|
||||
{
|
||||
// add stock
|
||||
$stock_manager = StockManagerFactory::getManager();
|
||||
$price = str_replace(',', '.', $product->wholesale_price);
|
||||
if ($price == 0)
|
||||
$price = 0.000001;
|
||||
$price = round(floatval($price), 6);
|
||||
$warehouse = new Warehouse($product->warehouse);
|
||||
if ($stock_manager->addProduct((int)$product->id, 0, $warehouse, $product->quantity, 1, $price, true))
|
||||
StockAvailable::synchronize((int)$product->id);
|
||||
}
|
||||
}
|
||||
// if not depends_on_stock set, use normal qty
|
||||
else
|
||||
{
|
||||
if (Shop::isFeatureActive())
|
||||
foreach ($shops as $shop)
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, (int)$shop);
|
||||
else
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id);
|
||||
}
|
||||
}
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
@@ -1886,11 +1988,11 @@ class AdminImportControllerCore extends AdminController
|
||||
else
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
|
||||
|
||||
// fils groups attributes
|
||||
// fills groups attributes
|
||||
$id_attribute_group = $obj->id;
|
||||
$groups_attributes[$key]['id'] = $id_attribute_group;
|
||||
}
|
||||
else // alreay exists
|
||||
else // already exists
|
||||
{
|
||||
$id_attribute_group = $groups[$group];
|
||||
$groups_attributes[$key]['id'] = $id_attribute_group;
|
||||
@@ -2041,7 +2143,87 @@ class AdminImportControllerCore extends AdminController
|
||||
VALUES ('.(int)$attribute_to_add.','.(int)$id_product_attribute.')');
|
||||
}
|
||||
|
||||
StockAvailable::setQuantity($product->id, $id_product_attribute, (int)$info['quantity']);
|
||||
// set advanced stock managment
|
||||
if (isset($info['advanced_stock_management']))
|
||||
{
|
||||
if ($info['advanced_stock_management'] != 1 && $info['advanced_stock_management'] != 0)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management has incorrect value. Not set for product with id %s '),$product->id);
|
||||
elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $info['advanced_stock_management'] == 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, can not enable on product with id %s '),$product->id);
|
||||
else
|
||||
$product->setAdvancedStockManagement($info['advanced_stock_management']);
|
||||
// automaticly disable depends on stock, if a_s_m set to disabled
|
||||
if (StockAvailable::dependsOnStock($product->id) == 1 && $info['advanced_stock_management'] == 0)
|
||||
StockAvailable::setProductDependsOnStock($product->id, 0,null,$id_product_attribute);
|
||||
}
|
||||
|
||||
// Check if warehouse exists
|
||||
if ($info['warehouse'])
|
||||
{
|
||||
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, warehouse not set on product with id %s '),$product->id);
|
||||
else
|
||||
{
|
||||
if (Warehouse::exists($info['warehouse']))
|
||||
{
|
||||
$warehouse_location_entity = new WarehouseProductLocation();
|
||||
$warehouse_location_entity->id_product = $product->id;
|
||||
$warehouse_location_entity->id_product_attribute = $id_product_attribute;
|
||||
$warehouse_location_entity->id_warehouse = $info['warehouse'];
|
||||
if (WarehouseProductLocation::getProductLocation($product->id, $id_product_attribute, $info['warehouse']) !== false)
|
||||
$warehouse_location_entity->update();
|
||||
else
|
||||
$warehouse_location_entity->save();
|
||||
StockAvailable::synchronize($product->id);
|
||||
}
|
||||
else
|
||||
$this->warnings[] = sprintf(Tools::displayError('Warehouse did not exists, can not set on product %1$s '),$product->name[$default_language_id]);
|
||||
}
|
||||
}
|
||||
|
||||
// stock available
|
||||
if (isset($info['depends_on_stock']))
|
||||
{
|
||||
if ($info['depends_on_stock'] != 0 && $info['depends_on_stock'] != 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Incorrect value for depends on stock for product %1$s '),$product->name[$default_language_id]);
|
||||
elseif ((!$info['advanced_stock_management'] || $info['advanced_stock_management'] == 0) && $info['depends_on_stock'] == 1)
|
||||
$this->warnings[] = sprintf(Tools::displayError('Advanced stock management not enabled, can not set depends on stock %1$s '),$product->name[$default_language_id]);
|
||||
else
|
||||
StockAvailable::setProductDependsOnStock($product->id, $info['depends_on_stock'],null,$id_product_attribute);
|
||||
|
||||
// This code allows us to set qty and disable depends on stock
|
||||
if (isset($info['quantity']) && $info['depends_on_stock'] == 0)
|
||||
{
|
||||
if (Shop::isFeatureActive())
|
||||
foreach ($shops as $shop)
|
||||
StockAvailable::setQuantity((int)$product->id, $id_product_attribute, (int)$info['quantity'], (int)$shop);
|
||||
else
|
||||
StockAvailable::setQuantity((int)$product->id, $id_product_attribute, (int)$info['quantity'], $this->context->shop->id);
|
||||
}
|
||||
// elseif enable depends on stock and quantity, add quantity to stock
|
||||
elseif (isset($info['quantity']) && $info['depends_on_stock'] == 1)
|
||||
{
|
||||
// add stock
|
||||
$stock_manager = StockManagerFactory::getManager();
|
||||
$price = str_replace(',', '.', $info['wholesale_price']);
|
||||
if ($price == 0)
|
||||
$price = 0.000001;
|
||||
$price = round(floatval($price), 6);
|
||||
$warehouse = new Warehouse($info['warehouse']);
|
||||
if ($stock_manager->addProduct((int)$product->id, $id_product_attribute, $warehouse, (int)$info['quantity'], 1, $price, true))
|
||||
StockAvailable::synchronize((int)$product->id);
|
||||
}
|
||||
}
|
||||
// if not depends_on_stock set, use normal qty
|
||||
else
|
||||
{
|
||||
if (Shop::isFeatureActive())
|
||||
foreach ($shops as $shop)
|
||||
StockAvailable::setQuantity((int)$product->id, $id_product_attribute, (int)$info['quantity'], (int)$shop);
|
||||
else
|
||||
StockAvailable::setQuantity((int)$product->id, $id_product_attribute, (int)$info['quantity'], $this->context->shop->id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,47 @@ class AdminLogsControllerCore extends AdminController
|
||||
$this->noLink = true;
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'employee' => array('title' => $this->l('Employee'), 'align' => 'center', 'havingFilter' => true),
|
||||
'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'message' => array('title' => $this->l('Message')),
|
||||
'object_type' => array('title' => $this->l('Object type'), 'class' => 'fixed-width-sm'),
|
||||
'object_id' => array('title' => $this->l('Object ID'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'error_code' => array('title' => $this->l('Error code'), 'align' => 'center', 'prefix' => '0x', 'class' => 'fixed-width-xs'),
|
||||
'date_add' => array('title' => $this->l('Date'), 'width' => 150, 'align' => 'right', 'type' => 'datetime')
|
||||
'id_log' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'employee' => array(
|
||||
'title' => $this->l('Employee'),
|
||||
'align' => 'left',
|
||||
'havingFilter' => true,
|
||||
'callback' => 'displayEmployee',
|
||||
'callback_object' => $this
|
||||
),
|
||||
'severity' => array(
|
||||
'title' => $this->l('Severity (1-4)'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'message' => array(
|
||||
'title' => $this->l('Message')
|
||||
),
|
||||
'object_type' => array(
|
||||
'title' => $this->l('Object type'),
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
'object_id' => array(
|
||||
'title' => $this->l('Object ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'error_code' => array(
|
||||
'title' => $this->l('Error code'),
|
||||
'align' => 'center',
|
||||
'prefix' => '0x',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Date'),
|
||||
'width' => 150,
|
||||
'align' => 'right',
|
||||
'type' => 'datetime'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
@@ -81,6 +114,12 @@ class AdminLogsControllerCore extends AdminController
|
||||
);
|
||||
unset($this->toolbar_btn['new']);
|
||||
}
|
||||
|
||||
public function displayEmployee($value, $tr)
|
||||
{
|
||||
$employee = new Employee((int)$tr['id_employee']);
|
||||
return ImageManager::thumbnail($employee->getImage(), $this->table.'_mini_'.$value.'_'.$this->context->shop->id.'.'.$this->imageType, 45, $this->imageType).' '.$value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -39,6 +39,10 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$this->multishop_context = Shop::CONTEXT_ALL;
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_warehouse' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'width' => 50,
|
||||
),
|
||||
'reference' => array(
|
||||
'title' => $this->l('Reference'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user