diff --git a/src/modules/mo/mo_dhl/Controller/Admin/DeliverySetDHLController.php b/src/modules/mo/mo_dhl/Controller/Admin/DeliverySetDHLController.php index 742365e..4b22d04 100644 --- a/src/modules/mo/mo_dhl/Controller/Admin/DeliverySetDHLController.php +++ b/src/modules/mo/mo_dhl/Controller/Admin/DeliverySetDHLController.php @@ -8,6 +8,7 @@ namespace Mediaopt\DHL\Controller\Admin; +use Mediaopt\DHL\Install; use Mediaopt\DHL\Model\MoDHLInternetmarkeProductList; use Mediaopt\DHL\Shipment\Participation; use Mediaopt\DHL\Shipment\Process; @@ -33,6 +34,11 @@ public function render() if (isset($id) && $id != "-1") { $deliverySet = oxNew(\OxidEsales\Eshop\Application\Model\DeliverySet::class); $deliverySet->load($id); + if ($deliverySet->getFieldData('mo_dhl_process') === 'WARENPOST') { + Install::changeWarenpostToKleinpaket(); + $deliverySet->oxdeliveryset__mo_dhl_process->setValue(Process::KLEINPAKET); + $deliverySet->load($id); + } $this->addTplParam("edit", $deliverySet); if ($deliverySet->isDerived()) { $this->addTplParam('readonly', true); diff --git a/src/modules/mo/mo_dhl/Controller/Admin/OrderDHLController.php b/src/modules/mo/mo_dhl/Controller/Admin/OrderDHLController.php index dd969b7..057d80c 100755 --- a/src/modules/mo/mo_dhl/Controller/Admin/OrderDHLController.php +++ b/src/modules/mo/mo_dhl/Controller/Admin/OrderDHLController.php @@ -12,6 +12,7 @@ use Mediaopt\DHL\Api\ParcelShipping\Client; use Mediaopt\DHL\Api\ParcelShipping\Model\ShipmentOrderRequest; use Mediaopt\DHL\Api\Wunschpaket; +use Mediaopt\DHL\Install; use Mediaopt\DHL\Merchant\Ekp; use Mediaopt\DHL\Model\MoDHLInternetmarkeRefund; use Mediaopt\DHL\Model\MoDHLLabel; @@ -265,6 +266,11 @@ protected function getParticipationNumber() protected function getProcess() { if ($processNr = $this->getOrder()->oxorder__mo_dhl_process->rawValue) { + if ($processNr === 'WARENPOST') { + Install::changeWarenpostToKleinpaket(); + $this->order->oxorder__mo_dhl_process->setValue('KLEINPAKET'); + $processNr = 'KLEINPAKET'; + } return Process::build($processNr); } return null; diff --git a/src/modules/mo/mo_dhl/Install.php b/src/modules/mo/mo_dhl/Install.php index 6aaa976..330558c 100644 --- a/src/modules/mo/mo_dhl/Install.php +++ b/src/modules/mo/mo_dhl/Install.php @@ -28,9 +28,17 @@ public static function onActivate() static::addColumns(); static::alterColumns(); static::ensureDocumentsFolderExists(); + static::changeWarenpostToKleinpaket(); static::cleanUp(); } + public static function changeWarenpostToKleinpaket() + { + $db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(); + $db->execute("UPDATE oxorder SET MO_DHL_PROCESS = 'KLEINPAKET' WHERE MO_DHL_PROCESS = 'WARENPOST'"); + $db->execute("UPDATE oxdeliveryset SET MO_DHL_PROCESS = 'KLEINPAKET' WHERE MO_DHL_PROCESS = 'WARENPOST'"); + } + protected static function ensureDocumentsFolderExists() { $path = Registry::get(ViewConfig::class)->getModulePath('mo_dhl', '') . 'documents';