Display errors
This commit is contained in:
@@ -4009,21 +4009,29 @@ class AdminControllerCore extends Controller
|
||||
* @return bool true if success
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
protected function processBulkStatusSelection($status, $redirect = true)
|
||||
protected function processBulkStatusSelection($status)
|
||||
{
|
||||
$result = true;
|
||||
if (is_array($this->boxes) && !empty($this->boxes)) {
|
||||
foreach ($this->boxes as $id) {
|
||||
/** @var ObjectModel $object */
|
||||
$object = new $this->className((int)$id);
|
||||
$object->setFieldsToUpdate(array('active' => true));
|
||||
$object->active = (int)$status;
|
||||
$result &= $object->update();
|
||||
}
|
||||
}
|
||||
$object = new $this->className((int) $id);
|
||||
$object->active = (int) $status;
|
||||
$isUpdated = (bool) $object->update();
|
||||
$result &= $isUpdated;
|
||||
|
||||
if ($redirect && $result) {
|
||||
$this->redirect_after = self::$currentIndex.'&conf=5&token='.$this->token;
|
||||
if (!$isUpdated) {
|
||||
$this->errors[] = sprintf($this->l('Can\'t update #%d status.'), (int) $id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$this->redirect_after = self::$currentIndex.'&conf=5&token='.$this->token;
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while updating the status.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('You must select at least one item to perform a bulk action.');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user