/** * @param $name * @return bool * @throws Mage_Core_Exception */ public function run($name) { $catId = $this->getCategoryId($name); $collection = $this->{$name}(); // call a function of this class using the action param from the form $this->_deleteInCategory($catId); $sql = $this->_addProductsToCategorySQL($collection, $catId); try { $this->_writeConnection->query($sql); $this->_reindexCategoryAndProduct(); } catch (Exception $e) { Mage::throwException($e); } return true; }
/** * Delete a list of ids from the `core_url_rewrite` table * * @param $deleteList int[] - List of ids to delete * @return int - Nr of ids deleted */ protected function cleanRewrites($deleteList) { $count = 0; if (!empty($deleteList)) { $chunks = array_chunk($deleteList, 100); foreach ($chunks as $chunk) { $sql = sprintf('DELETE FROM %s WHERE `url_rewrite_id` IN (%s)', $this->writeAdapter->quoteIdentifier($this->table), $this->writeAdapter->quote($chunk)); $stmt = $this->writeAdapter->query($sql); $count += $stmt->rowCount(); $stmt->closeCursor(); } echo "."; flush(); } return $count; }