public function sortproductsAction() { if ($rows = $this->getRequest()->getParam('product')) { $html = array(); try { if (!$this->getCurrentOptionValue()) { throw new Exception('Une erreur est survenue lors de la sauvegarde.'); } $product = new Catalog_Model_Product(); $products = $product->findByValueId($this->getCurrentOptionValue()->getId()); $product_ids = array(); foreach ($products as $product) { $product_ids[] = $product->getId(); } foreach ($rows as $key => $row) { if (!in_array($row, $product_ids)) { throw new Exception($this->_('An error occurred while saving. One of your products could not be identified.')); } } $product->updatePosition($rows); $html = array('success' => 1); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }