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 @@