Merge pull request #21749 from vdegrandpre/develop

CLOSE 21748 Maillage sur ErrorProductAlreadyExists en créant produit
This commit is contained in:
Laurent Destailleur 2022-08-14 16:16:08 +02:00 committed by GitHub
commit 29499ce52f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* Copyright (C) 2022 Vincent de Grandpré <vincent@de-grandpre.quebec>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -666,7 +667,20 @@ if (empty($reshook)) {
if (count($object->errors)) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans($object->error), null, 'errors');
if ($object->error == 'ErrorProductAlreadyExists') {
// allow to hook on ErrorProductAlreadyExists in any module
$reshook = $hookmanager->executeHooks('onProductAlreadyExists', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if ($object->error) {
// check again to prevent translation issue,
// as error may have been cleared in hook function
setEventMessages($langs->trans($object->error), null, 'errors');
}
} else {
setEventMessages($langs->trans($object->error), null, 'errors');
}
}
$action = "create";
}