public function ajaxProcessUpdatePositions() { if ($this->tabAccess['edit'] === '1') { $way = (int) Tools::getValue('way'); $id_product = (int) Tools::getValue('id_product'); $id_category = (int) Tools::getValue('id_category'); $positions = Tools::getValue('product'); if (is_array($positions)) { foreach ($positions as $position => $value) { $pos = explode('_', $value); if (isset($pos[1]) && isset($pos[2]) && ($pos[1] == $id_category && (int) $pos[2] === $id_product)) { if ($product = new Product((int) $pos[2])) { if (isset($position) && $product->updatePosition($way, $position)) { $category = new Category((int) $id_category); if (Validate::isLoadedObject($category)) { hook::Exec('categoryUpdate', array('category' => $category)); } echo 'ok position ' . (int) $position . ' for product ' . (int) $pos[2] . "\r\n"; } else { echo '{"hasError" : true, "errors" : "Can not update product ' . (int) $id_product . ' to position ' . (int) $position . ' "}'; } } else { echo '{"hasError" : true, "errors" : "This product (' . (int) $id_product . ') can t be loaded"}'; } break; } } } } }