From 489609937e9de15f731370a4c5632821fd727710 Mon Sep 17 00:00:00 2001 From: TLabutis Date: Fri, 4 Sep 2026 08:36:29 +0300 Subject: [PATCH] Stop reporting every import failure as a large-country timeout The parcel shop import error handler treated HTTP 500 the same as a timeout, so any server-side fatal opened the "Automatic Update Required" modal claiming the country has too many pick-up points. Merchants then ran the suggested cron command and hit the same fatal from the CLI, with no error ever surfacing in the UI. Only status 'timeout' and HTTP 504 now open that modal; a 500 shows a real error message pointing at the DPD logs page. The modal copy no longer asserts the country is large, and the cron command it prints uses --country= for the selected country instead of --all, matching what AdminDPDBalticsAjaxController already returns in cron_command. The underlying LT import fatal (Unirest\Request called statically) lives in invertus/dpdbaltics-api and is not addressed here. --- CHANGELOG.md | 4 +++ .../AdminDPDBalticsImportExportController.php | 6 +++- views/js/admin/import/import_parcels.js | 36 +++++++++++++++---- .../admin/import/importing-parcels-popup.tpl | 6 ++-- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d64c9d10..51ef4a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -204,3 +204,7 @@ - Added timeframes to shipment request - Fixed phone area code, city and street select width rendering as 0px when switching carriers in checkout - Fixed DPDBaltics menu item disappearing from sidebar when navigating to module pages + +## [3.3.2] +- Fixed pick-up point import reporting any server error as "this country has many pick-up points", which hid the real failure +- Fixed the suggested cron command to target the selected country instead of updating every country diff --git a/controllers/admin/AdminDPDBalticsImportExportController.php b/controllers/admin/AdminDPDBalticsImportExportController.php index 265220d8..40f17880 100644 --- a/controllers/admin/AdminDPDBalticsImportExportController.php +++ b/controllers/admin/AdminDPDBalticsImportExportController.php @@ -76,7 +76,11 @@ public function postProcess() $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), 'successMessage' => $this->module->l('Parcels successfully updated'), 'failMessage' => $this->module->l('Parcels update failed'), - 'countryId' => Tools::getValue('DPD_PARCEL_IMPORT_COUNTRY_SELECTOR') + 'serverErrorMessage' => $this->module->l('The import failed on the server. Check the DPD logs page for the full error.'), + 'countryId' => Tools::getValue('DPD_PARCEL_IMPORT_COUNTRY_SELECTOR'), + 'countryIso' => Country::getIsoById( + (int) Tools::getValue('DPD_PARCEL_IMPORT_COUNTRY_SELECTOR') + ) ]); $this->addJS($this->getModuleJSUri() . 'import/import_parcels.js'); diff --git a/views/js/admin/import/import_parcels.js b/views/js/admin/import/import_parcels.js index c3f99b35..fe0a55a1 100644 --- a/views/js/admin/import/import_parcels.js +++ b/views/js/admin/import/import_parcels.js @@ -53,14 +53,28 @@ $(window).load(function () { } }, error: function(xhr, status, error) { - if (status === 'timeout' || xhr.status === 500 || xhr.status === 504) { - // Server timeout - show cron modal - showCronRequiredModal('php bin/console dpdbaltics:update-parcel-shops --all'); - } else if (xhr.status === 0) { + // Only a real timeout justifies the cron advice; a 500 would fail under cron too. + if (status === 'timeout' || xhr.status === 504) { + showCronRequiredModal(buildCronCommand()); + + return; + } + + if (xhr.status === 500) { + showErrorMessage(typeof serverErrorMessage !== 'undefined' + ? serverErrorMessage + : 'The import failed on the server. Check the DPD logs page for the full error.'); + + return; + } + + if (xhr.status === 0) { showErrorMessage('Network error. Please check your connection.'); - } else { - showErrorMessage('Import failed: ' + (error || status || 'Unknown error')); + + return; } + + showErrorMessage('Import failed: ' + (error || status || 'Unknown error')); }, complete: function () { // Hide image container @@ -86,9 +100,17 @@ $(window).load(function () { clearInterval(toggleInterval); } + function buildCronCommand() { + if (typeof countryIso !== 'undefined' && countryIso) { + return 'php bin/console dpdbaltics:update-parcel-shops --country=' + countryIso; + } + + return 'php bin/console dpdbaltics:update-parcel-shops --all'; + } + function showCronRequiredModal(cronCommand) { var $modal = $('#import-cron-required-modal'); - $('#cron-command-display').text(cronCommand || 'php bin/console dpdbaltics:update-parcel-shops --all'); + $('#cron-command-display').text(cronCommand || buildCronCommand()); $modal.modal('show'); } diff --git a/views/templates/admin/import/importing-parcels-popup.tpl b/views/templates/admin/import/importing-parcels-popup.tpl index a710d100..335ff50d 100644 --- a/views/templates/admin/import/importing-parcels-popup.tpl +++ b/views/templates/admin/import/importing-parcels-popup.tpl @@ -62,13 +62,13 @@