[-] BO: fix PSCFV-3681 - addresses of warehouses cant be updated
This commit is contained in:
@@ -501,51 +501,55 @@ class AdminWarehousesControllerCore extends AdminController
|
|||||||
if (!($obj = $this->loadObject(true)))
|
if (!($obj = $this->loadObject(true)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// updates/creates address if it does not exist
|
$this->updateAddress();
|
||||||
if (Tools::isSubmit('id_address') && (int)Tools::getValue('id_address') > 0)
|
|
||||||
$address = new Address((int)Tools::getValue('id_address')); // updates address
|
|
||||||
else
|
|
||||||
$address = new Address(); // creates address
|
|
||||||
|
|
||||||
// sets the address
|
|
||||||
$address->alias = Tools::getValue('reference', null);
|
|
||||||
$address->lastname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
|
||||||
$address->firstname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
|
||||||
$address->address1 = Tools::getValue('address', null);
|
|
||||||
$address->address2 = Tools::getValue('address2', null);
|
|
||||||
$address->postcode = Tools::getValue('postcode', null);
|
|
||||||
$address->phone = Tools::getValue('phone', null);
|
|
||||||
$address->id_country = Tools::getValue('id_country', null);
|
|
||||||
$address->id_state = Tools::getValue('id_state', null);
|
|
||||||
$address->city = Tools::getValue('city', null);
|
|
||||||
|
|
||||||
// validates the address
|
|
||||||
$validation = $address->validateController();
|
|
||||||
|
|
||||||
// checks address validity
|
|
||||||
if (count($validation) > 0) // if not valid
|
|
||||||
{
|
|
||||||
foreach ($validation as $item)
|
|
||||||
$this->errors[] = $item;
|
|
||||||
$this->errors[] = Tools::displayError('The address is not correct. Check if all required fields are filled.');
|
|
||||||
}
|
|
||||||
else // valid
|
|
||||||
{
|
|
||||||
if (Tools::isSubmit('id_address') && Tools::getValue('id_address') > 0)
|
|
||||||
$address->update();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$address->save();
|
|
||||||
$_POST['id_address'] = $address->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
return parent::processAdd();
|
return parent::processAdd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function updateAddress()
|
||||||
|
{
|
||||||
|
// updates/creates address if it does not exist
|
||||||
|
if (Tools::isSubmit('id_address') && (int)Tools::getValue('id_address') > 0)
|
||||||
|
$address = new Address((int)Tools::getValue('id_address')); // updates address
|
||||||
|
else
|
||||||
|
$address = new Address(); // creates address
|
||||||
|
// sets the address
|
||||||
|
$address->alias = Tools::getValue('reference', null);
|
||||||
|
$address->lastname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
||||||
|
$address->firstname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
||||||
|
$address->address1 = Tools::getValue('address', null);
|
||||||
|
$address->address2 = Tools::getValue('address2', null);
|
||||||
|
$address->postcode = Tools::getValue('postcode', null);
|
||||||
|
$address->phone = Tools::getValue('phone', null);
|
||||||
|
$address->id_country = Tools::getValue('id_country', null);
|
||||||
|
$address->id_state = Tools::getValue('id_state', null);
|
||||||
|
$address->city = Tools::getValue('city', null);
|
||||||
|
|
||||||
|
// validates the address
|
||||||
|
$validation = $address->validateController();
|
||||||
|
|
||||||
|
// checks address validity
|
||||||
|
if (count($validation) > 0) // if not valid
|
||||||
|
{
|
||||||
|
foreach ($validation as $item)
|
||||||
|
$this->errors[] = $item;
|
||||||
|
$this->errors[] = Tools::displayError('The address is not correct. Check if all required fields are filled.');
|
||||||
|
}
|
||||||
|
else // valid
|
||||||
|
{
|
||||||
|
if (Tools::isSubmit('id_address') && Tools::getValue('id_address') > 0)
|
||||||
|
$address->update();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$address->save();
|
||||||
|
$_POST['id_address'] = $address->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AdminController::processDelete();
|
* @see AdminController::processDelete();
|
||||||
@@ -585,7 +589,7 @@ class AdminWarehousesControllerCore extends AdminController
|
|||||||
// loads object
|
// loads object
|
||||||
if (!($obj = $this->loadObject(true)))
|
if (!($obj = $this->loadObject(true)))
|
||||||
return;
|
return;
|
||||||
|
$this->updateAddress();
|
||||||
// handles carriers associations
|
// handles carriers associations
|
||||||
$obj->setCarriers(Tools::getValue('ids_carriers'), array());
|
$obj->setCarriers(Tools::getValue('ids_carriers'), array());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user