// Fixed Carriers/Shop associations with Warehouses

This commit is contained in:
bMancone committed 2012-01-11 10:11:38 +00:00
1 parent 2dfa2aca26
commit 5b3e36e0ca
1 file changed
+22 -7
@@ -226,6 +226,7 @@ class AdminWarehousesControllerCore extends AdminController
'name' => 'id_state', 'name' => 'id_state',
'required' => true, 'required' => true,
'options' => array( 'options' => array(
'query' => array(),
'id' => 'id_state', 'id' => 'id_state',
'name' => 'name' 'name' => 'name'
) )
@@ -384,13 +385,6 @@ class AdminWarehousesControllerCore extends AdminController
if (!($obj = $this->loadObject(true))) if (!($obj = $this->loadObject(true)))
return; return;
// handles shops associations
if (Tools::isSubmit('ids_shops'))
$obj->setShops(Tools::getValue('ids_shops'));
// handles carriers associations
$obj->setCarriers(Tools::getValue('ids_carriers'));
// updates/creates address if it does not exist // updates/creates address if it does not exist
if (Tools::isSubmit('id_address') && (int)Tools::getValue('id_address') > 0) if (Tools::isSubmit('id_address') && (int)Tools::getValue('id_address') > 0)
$address = new Address((int)Tools::getValue('id_address')); // updates address $address = new Address((int)Tools::getValue('id_address')); // updates address
@@ -428,6 +422,18 @@ class AdminWarehousesControllerCore extends AdminController
} }
} }
// if updating
if ($obj->id > 0)
{
// handles shops associations
if (Tools::isSubmit('ids_shops'))
$obj->setShops(Tools::getValue('ids_shops'));
// handles carriers associations
if (Tools::isSubmit('ids_carriers'))
$obj->setCarriers(Tools::getValue('ids_carriers'));
}
// hack for enable the possibility to update a warehouse without recreate new id // hack for enable the possibility to update a warehouse without recreate new id
$this->deleted = false; $this->deleted = false;
@@ -500,6 +506,15 @@ class AdminWarehousesControllerCore extends AdminController
$address->id_warehouse = $object->id_address; $address->id_warehouse = $object->id_address;
$address->save(); $address->save();
} }
// handles shops associations
if (Tools::isSubmit('ids_shops'))
$object->setShops(Tools::getValue('ids_shops'));
// handles carriers associations
if (Tools::isSubmit('ids_carriers'))
$object->setCarriers(Tools::getValue('ids_carriers'));
return true; return true;
} }
} }