0

we did a complete re-index of our store. The core_url_rewrite table is full with around 288,000 entries. We have just over 40,000 Products and 6 StoreViews defined, with 5 currently being active.

However, the front end gives us 404 errors for SEO friendly urls.

In the backend, if I try to have a look at Catalog -> Rewrite URL Management, I receive the following error:

"Item (Mage_Core_Model_Url_Rewrite) with the same id "0" already exist"

When I check the core_url_rewrite table, all the url_rewrite_id's are 0! I would have thought these would auto_increment?

I think the the DB Table was create wrongly without any auto-increment!

a:5:{i:0;s:69:"Item (Mage_Core_Model_Url_Rewrite) with the same id "0" already exist";i:1;s:4054:"#0 /html/magento/lib/Varien/Data/Collection/Db.php(576): Varien_Data_Collection->addItem(Object(Mage_Core_Model_Url_Rewrite))
#1 /html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(533): Varien_Data_Collection_Db->load()
#2 /html/magento/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php(48): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
#3 /html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(626): Mage_Adminhtml_Block_Urlrewrite_Grid->_prepareCollection()
#4 /html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(632): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
#5 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(918): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
#6 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#7 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('grid', true)
#8 /html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php(77): Mage_Core_Block_Abstract->getChildHtml('grid')
#9 /html/magento/app/design/adminhtml/default/default/template/widget/grid/container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml()
#10 /html/magento/app/code/core/Mage/Core/Block/Template.php(241): include('/html/magento/a...')
#11 /html/magento/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#12 /html/magento/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#13 /html/magento/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#14 /html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Container.php(308): Mage_Adminhtml_Block_Template->_toHtml()
#15 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Widget_Container->_toHtml()
#16 /html/magento/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#17 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#18 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#19 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#20 /html/magento/app/design/adminhtml/default/default/template/page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content')
#21 /html/magento/app/code/core/Mage/Core/Block/Template.php(241): include('/html/magento/a...')
#22 /html/magento/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#23 /html/magento/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#24 /html/magento/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#25 /html/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#26 /html/magento/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#27 /html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#28 /html/magento/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php(74): Mage_Core_Controller_Varien_Action->renderLayout()
#29 /html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_UrlrewriteController->indexAction()
#30 /html/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#31 /html/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#32 /html/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#33 /html/magento/app/Mage.php(699): Mage_Core_Model_App->run(Array)
#34 /html/magento/index.php(98): Mage::run('', 'store')
#35 {main}";s:3:"url";s:77:"/index.php/admin/admin/urlrewrite/index/key/78b5386c722edee4e716f0c81bb03114/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}

Does anyone know what the problem is and how I can fix this?

If a fix is possible without a complete re-index that would be grand!

Thanks.

1

When I check the core_url_rewrite table, all the url_rewrite_id's are 0! These should AUTO_INCREMENT.

So the the DB Table was create wrongly without any auto-increment!

I have to delete and re-create the table with AUTO_INCREMENT.

here are the table details:

WRONG:

CREATE TABLE `core_url_rewrite` (
  `url_rewrite_id` int(10) unsigned NOT NULL COMMENT 'Rewrite Id',
  `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store Id',
  `id_path` varchar(255) DEFAULT NULL COMMENT 'Id Path',
  `request_path` varchar(255) DEFAULT NULL COMMENT 'Request Path',
  `target_path` varchar(255) DEFAULT NULL COMMENT 'Target Path',
  `is_system` smallint(5) unsigned DEFAULT '1' COMMENT 'Defines is Rewrite System',
  `options` varchar(255) DEFAULT NULL COMMENT 'Options',
  `description` varchar(255) DEFAULT NULL COMMENT 'Deascription',
  `category_id` int(10) unsigned DEFAULT NULL COMMENT 'Category Id',
  `product_id` int(10) unsigned DEFAULT NULL COMMENT 'Product Id'
) TYPE=InnoDB COMMENT='Url Rewrites';

RIGHT SHOULD BE:

CREATE TABLE `core_url_rewrite` (
  `url_rewrite_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Rewrite Id',
  `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store Id',
  `id_path` varchar(255) DEFAULT NULL COMMENT 'Id Path',
  `request_path` varchar(255) DEFAULT NULL COMMENT 'Request Path',
  `target_path` varchar(255) DEFAULT NULL COMMENT 'Target Path',
  `is_system` smallint(5) unsigned DEFAULT '1' COMMENT 'Defines is Rewrite System',
  `options` varchar(255) DEFAULT NULL COMMENT 'Options',
  `description` varchar(255) DEFAULT NULL COMMENT 'Deascription',
  `category_id` int(10) unsigned DEFAULT NULL COMMENT 'Category Id',
  `product_id` int(10) unsigned DEFAULT NULL COMMENT 'Product Id',
  PRIMARY KEY (`url_rewrite_id`),
  UNIQUE KEY `UNQ_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID` (`request_path`,`store_id`),
  UNIQUE KEY `UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID` (`id_path`,`is_system`,`store_id`),
  KEY `IDX_CORE_URL_REWRITE_TARGET_PATH_STORE_ID` (`target_path`,`store_id`),
  KEY `IDX_CORE_URL_REWRITE_ID_PATH` (`id_path`),
  KEY `IDX_CORE_URL_REWRITE_STORE_ID` (`store_id`),
  KEY `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` (`category_id`),
  KEY `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_CATEGORY_ENTITY_ENTITY_ID` (`product_id`),
  CONSTRAINT `FK_CORE_URL_REWRITE_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID` FOREIGN KEY (`category_id`) REFERENCES `catalog_category_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_CORE_URL_REWRITE_PRODUCT_ID_CATALOG_CATEGORY_ENTITY_ENTITY_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_CORE_URL_REWRITE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='Url Rewrites';

To avoid re-indexing I copied the values from the wrong table to the new excluding the id value using:

INSERT IGNORE INTO _core_url_rewrite (store_id, id_path, request_path, target_path, is_system, options, description, category_id, product_id)
SELECT Distinct store_id, id_path, request_path, target_path, is_system, options, description, category_id, product_id
FROM core_url_rewrite

Then I removed the wrong table and renamed the correct table. Now all is working fine.

=)

0
  1. Locate var/locks directory and remove all files under this directory. This will clear all the locks for re-indexing to take place again.

  2. Now, login to your MysQSL/phpMyAdmin to run the following MySQL query (Ensure that your have taken full backup before committing this MySQL query)

    DELETE cpop.* FROM catalog_product_option_price AS cpop INNER JOIN catalog_product_option AS cpo ON cpo.option_id = cpop.option_id WHERE cpo.type = 'checkbox' OR cpo.type = 'radio' OR cpo.type = 'drop_down';

    DELETE cpotp.* FROM catalog_product_option_type_price AS cpotp INNER JOIN catalog_product_option_type_value AS cpotv ON cpotv.option_type_id = cpotp.option_type_id INNER JOIN catalog_product_option AS cpo ON cpotv.option_id = cpo.option_id WHERE cpo.type <> 'checkbox' AND cpo.type <> 'radio' AND cpo.type <> 'drop_down';

  3. Log back in to your Magento Admin panel and go to System tab > Index Management hit index again and you will notice no such errors will appear again. You can follow these same steps again if re-indexing stops in future to resolve Magento ReIndexing issues.

  • Thanks for this answer, however this will not fix my problem, as the table core_url_rewrite seems to have been created without an AUTO_INCREMENT, thus all url_rewrite_id = 0 iunstead of increasing 1,2,3, etc .. – tecjam Sep 11 '15 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.