*/ /** * Since 1.13 new urls processing behaviour was introduced. * This tool creates URL redirects(301) for URLs that have been changed during upgrade. * Supplementary utility. */ require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Migration.php'; if (count($argv) != 3 || !is_numeric($argv[1]) || !is_numeric($argv[2])) { echo "Wrong parameters passed."; exit(100); } error_reporting(-1); ini_set('display_errors', 1); ini_set('memory_limit', -1); $page = $argv[1]; $batchSize = $argv[2]; $response = new Mage_Core_Controller_Response_Http(); Mage::app()->setResponse($response); $migration = new Mage_Migration(); $rewriteRequest = Mage::getModel('enterprise_urlrewrite/url_rewrite_request'); $rewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite'); $matchers = Mage::getSingleton('enterprise_urlrewrite/system_config_source_matcherPriority')->getRewriteMatchers(); $rewritesSelect = $migration->getConnection()->select()->from($migration->getResource()->getTableName('core_url_rewrite'), array('product_id', 'category_id', 'store_id', 'request_path'))->order('url_rewrite_id')->limit($batchSize, $page * $batchSize); foreach ($migration->getConnection()->fetchAll($rewritesSelect) as $rewriteInfo) { try { $migration->processRewrite($rewriteInfo, $rewriteRequest, $rewrite, $matchers, $migration->getResource()); } catch (Exception $e) { echo $e->getMessage() . "\n"; } } exit(0);
$processedCategories = array(); $processedProducts = array(); Mage::getModel('enterprise_mview/client')->init('enterprise_url_rewrite_category')->execute('enterprise_catalog/index_action_url_rewrite_category_refresh'); Mage::getModel('enterprise_mview/client')->init('enterprise_url_rewrite_product')->execute('enterprise_catalog/index_action_url_rewrite_product_refresh'); Mage::getModel('enterprise_mview/client')->init('enterprise_url_rewrite_redirect')->execute('enterprise_urlrewrite/index_action_url_rewrite_redirect_refresh'); $tableProducts = $migration->getConnection()->newTable($migration->getEntityMigrationTable(Mage_Migration::ENTITY_TYPE_PRODUCT))->addColumn('id', Varien_Db_Ddl_Table::TYPE_CHAR, 512); $tableCategories = $migration->getConnection()->newTable($migration->getEntityMigrationTable(Mage_Migration::ENTITY_TYPE_CATEGORY))->addColumn('id', Varien_Db_Ddl_Table::TYPE_CHAR, 512); if ($migration->getConnection()->isTableExists($tableProducts->getName())) { $migration->getConnection()->dropTable($tableProducts->getName()); } if ($migration->getConnection()->isTableExists($tableCategories->getName())) { $migration->getConnection()->dropTable($tableCategories->getName()); } $migration->getConnection()->createTable($tableProducts); $migration->getConnection()->createTable($tableCategories); $rewritesSelect = $migration->getConnection()->select()->from($migration->getResource()->getTableName('core_url_rewrite'), array('product_id', 'category_id', 'store_id', 'request_path'))->order('url_rewrite_id'); $cpbAdapter = new Zend_ProgressBar_Adapter_Console(array('elements' => array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_ETA, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT))); $countSelect = clone $rewritesSelect; $countSelect->reset(Zend_Db_Select::COLUMNS); $countSelect->columns('COUNT(*)'); $row = $migration->getConnection()->fetchRow($countSelect); $totalRows = array_shift($row); unset($countSelect); $logger->info('Renaming conflicting entities...'); $batchSize = 2000; $batches = ceil($totalRows / $batchSize); $progressBar = new Zend_ProgressBar($cpbAdapter, 0, $batches); $i = 0; $child = 'php -f ' . dirname(__FILE__) . '/umt113_conflict.php --'; $processesCheck = "ps x | grep \"{$child}\" | grep -v grep"; for (; $batches; $batches--) {