// Fixed #PSTEST-804

This commit is contained in:
bMancone committed 2012-02-28 15:35:37 +00:00
1 parent b3e8e6cb02
commit 63493b444a
3 files changed
+46 -3

No files matched your search

-1
View File
@@ -94,7 +94,6 @@ class ShopCore extends ObjectModel
'store' => array('type' => 'shop'), 'store' => array('type' => 'shop'),
'webservice_account' => array('type' => 'shop'), 'webservice_account' => array('type' => 'shop'),
'warehouse' => array('type' => 'shop'), 'warehouse' => array('type' => 'shop'),
/* 'stock_available' => array('type' => 'fk_shop', 'primary' => 'id_stock_available'), */
); );
protected $webserviceParameters = array( protected $webserviceParameters = array(
+32
View File
@@ -629,4 +629,36 @@ class StockAvailableCore extends ObjectModel
if (!$group_ok) if (!$group_ok)
$params['id_shop'] = (int)$id_shop; $params['id_shop'] = (int)$id_shop;
} }
/**
* Copies stock available content table
*
* @param int $src_shop_id
* @param int $dst_shop_id
* @return bool
*/
public static function copyStockAvailableFromShopToShop($src_shop_id, $dst_shop_id)
{
if (!$src_shop_id || !$dst_shop_id)
return false;
$query = '
INSERT INTO '._DB_PREFIX_.'stock_available
(
id_product,
id_product_attribute,
id_shop,
id_group_shop,
quantity,
depends_on_stock,
out_of_stock
)
(
SELECT id_product, id_product_attribute, '.(int)$dst_shop_id.', 0, quantity, depends_on_stock, out_of_stock
FROM '._DB_PREFIX_.'stock_available
WHERE id_shop = '.(int)$src_shop_id.
')';
return Db::getInstance()->execute($query);
}
} }
+14 -2
View File
@@ -405,6 +405,7 @@ class AdminShopControllerCore extends AdminController
'stock_available' => $this->l('Available quantities for sale'), 'stock_available' => $this->l('Available quantities for sale'),
'store' => $this->l('Stores'), 'store' => $this->l('Stores'),
'warehouse' => $this->l('Warehouse'), 'warehouse' => $this->l('Warehouse'),
'stock_available' => $this->l('Stock Available'),
); );
if (!$this->object->id) if (!$this->object->id)
@@ -496,8 +497,19 @@ class AdminShopControllerCore extends AdminController
if (count($this->errors) > 0) if (count($this->errors) > 0)
return; return;
// if we import datas from another shop, we do not update the shop categories // datas to import
$import_data = Tools::getValue('importData'); $import_data = Tools::getValue('importData');
// specific import for stock
if (isset($import_data['stock_available']) && isset($import_data['product']) && Tools::isSubmit('useImportData'))
{
$id_src_shop = (int)Tools::getValue('importFromShop');
$group = new GroupShop((int)Shop::getGroupFromShop($object->id));
if ($group->share_stock == false)
StockAvailable::copyStockAvailableFromShopToShop($id_src_shop, $object->id);
}
// if we import datas from another shop, we do not update the shop categories
if (!isset($import_data['category'])) if (!isset($import_data['category']))
Category::updateFromShop(Tools::getValue('categoryBox'), $object->id); Category::updateFromShop(Tools::getValue('categoryBox'), $object->id);
@@ -506,7 +518,7 @@ class AdminShopControllerCore extends AdminController
public function initCategoriesAssociation($id_root = 1) public function initCategoriesAssociation($id_root = 1)
{ {
$id_shop = Tools::getValue('id_shop'); $id_shop = (int)Tools::getValue('id_shop');
$shop = new Shop($id_shop); $shop = new Shop($id_shop);
$selected_cat = Shop::getCategories($id_shop); $selected_cat = Shop::getCategories($id_shop);
if (empty($selected_cat)) if (empty($selected_cat))