Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion controllers/admin/AdminDPDBalticsImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
36 changes: 29 additions & 7 deletions views/js/admin/import/import_parcels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}

Expand Down
6 changes: 3 additions & 3 deletions views/templates/admin/import/importing-parcels-popup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<i class="icon-info-circle"></i>
{l s='Automatic Update Required' mod='dpdbaltics'}
{l s='Update timed out' mod='dpdbaltics'}
</h4>
</div>
<div class="modal-body">
<div class="alert alert-info">
<p><strong>{l s='This country has many pick-up points and requires automatic updates.' mod='dpdbaltics'}</strong></p>
<p>{l s='Due to server limitations, large countries cannot be updated through the browser. Please set up automatic updates using the cron job below.' mod='dpdbaltics'}</p>
<p><strong>{l s='The update did not finish before your server closed the connection.' mod='dpdbaltics'}</strong></p>
<p>{l s='This usually happens when a country has a lot of pick-up points. Running the update from the command line has no time limit, so schedule the cron job below instead.' mod='dpdbaltics'}</p>
</div>

<div class="panel panel-default" style="margin-top: 15px;">
Expand Down
Loading