add button to clean image positions
This commit is contained in:
parent
d762e3e613
commit
bd9cdc9cad
@ -742,6 +742,39 @@ class AdminProducts extends AdminTab
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override - Antadis, clean image position when bug occured */
|
||||
elseif (Tools::isSubmit('cleanImagePositions') && Tools::getValue('id_product')){
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())){
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `id_product` = '. (int)$object->id .'
|
||||
ORDER BY position ASC') as $key => $value) {
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `position` = (`position` + 99)
|
||||
WHERE `id_image` = '. (int)$value['id_image']
|
||||
);
|
||||
}
|
||||
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `id_product` = '. (int)$object->id .'
|
||||
ORDER BY position ASC') as $key => $value) {
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `position` = '.($key+1).'
|
||||
WHERE `id_image` = '. (int)$value['id_image']
|
||||
);
|
||||
}
|
||||
|
||||
Tools::redirectAdmin($currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&update'.$this->table.'&tabs=1'.'&token='.($token ? $token : $this->token));
|
||||
} else {
|
||||
$this->_errors[] = Tools::displayError('Product doesn\'t exist');
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override - Antadis, delete some images in same time */
|
||||
elseif (Tools::isSubmit('deleteImages') && Tools::getValue('ids_image'))
|
||||
{
|
||||
@ -3980,7 +4013,10 @@ class AdminProducts extends AdminTab
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><button name="deleteImages" id="deleteImages" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Supprimer la selection').'</button></p>
|
||||
<p>
|
||||
<button name="deleteImages" id="deleteImages" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Supprimer la selection').'</button>
|
||||
<button name="cleanImagePositions" id="cleanImagePositions" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Cleaner les positions des images').'</button>
|
||||
</p>
|
||||
</div>';
|
||||
echo '
|
||||
<script type="text/javascript" src="../js/attributesBack.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user