EcomDev / EcomDev_UrlRewrite

Alternative implementation of Url Rewrite Index by EcomDev
72 stars 33 forks source link

Indexation fails with constraint violation #5

Open denos opened 12 years ago

denos commented 12 years ago

Indexation fails with this message

Catalog URL Rewrites index process unknown error: exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'product/100053/4-1-1' for key 'UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID'' in /home/www/magento3/lib/Zend/Db/Statement/Pdo.php:228 Stack trace:

0 /home/www/magento3/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)

1 /home/www/magento3/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

2 /home/www/magento3/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)

3 /home/www/magento3/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)

4 /home/www/magento3/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `co...', Array)

5 /home/www/magento3/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `co...', Array)

6 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Mysql4/Indexer.php(2040): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `co...')

7 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Mysql4/Indexer.php(2164): EcomDev_UrlRewrite_Model_Mysql4_Indexer->_updateRewrites()

8 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Indexer.php(97): EcomDev_UrlRewrite_Model_Mysql4_Indexer->reindexAll()

9 /home/www/magento3/app/code/core/Mage/Index/Model/Process.php(207): EcomDev_UrlRewrite_Model_Indexer->reindexAll()

10 /home/www/magento3/app/code/core/Mage/Index/Model/Process.php(253): Mage_Index_Model_Process->reindexAll()

11 /home/www/magento3/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()

12 /home/www/magento3/shell/indexer.php(198): Mage_Shell_Compiler->run()

13 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'product/100053/4-1-1' for key 'UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID'' in /home/www/magento3/lib/Zend/Db/Statement/Pdo.php:234 Stack trace:

0 /home/www/magento3/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

1 /home/www/magento3/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)

2 /home/www/magento3/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)

3 /home/www/magento3/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `co...', Array)

4 /home/www/magento3/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `co...', Array)

5 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Mysql4/Indexer.php(2040): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `co...')

6 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Mysql4/Indexer.php(2164): EcomDev_UrlRewrite_Model_Mysql4_Indexer->_updateRewrites()

7 /home/www/magento3/app/code/community/EcomDev/UrlRewrite/Model/Indexer.php(97): EcomDev_UrlRewrite_Model_Mysql4_Indexer->reindexAll()

8 /home/www/magento3/app/code/core/Mage/Index/Model/Process.php(207): EcomDev_UrlRewrite_Model_Indexer->reindexAll()

9 /home/www/magento3/app/code/core/Mage/Index/Model/Process.php(253): Mage_Index_Model_Process->reindexAll()

10 /home/www/magento3/shell/indexer.php(158): Mage_Index_Model_Process->reindexEverything()

11 /home/www/magento3/shell/indexer.php(198): Mage_Shell_Compiler->run()

12 {main}

Magento 1.6.2 with 200k products

IvanChepurnyi commented 12 years ago

The issue is in incorrect rewrite values you have in Magento. Please make sure that your custom rewrites do not have the same id path and system rewrites for now. The issue with not allowing this rewrites to be inserted in our table will be resolved in the next version.

paales commented 11 years ago

Please make sure that your custom rewrites do not have the same id path and system rewrites for now. The issue with not allowing this rewrites to be inserted in our table will be resolved in the next version.

I'm not doing custom rewrites at the moment but still got the following error:

Integrity constraint violation: 1062 Duplicate entry 'product/100/3-1-1' for key 'UNQ_CORE_URL_REWRITE_ID_PATH_IS_SYSTEM_STORE_ID'' in lib/Zend/Db/Statement/Pdo.php:228

Can this also be due to duplicate URL keys? There are some products that have duplicate URL keys.

paales commented 11 years ago

After clearing the core_url_rewrite table, everything worked as expected. Thanks for the module and your hard work on it, you saved the day (week probably)!

ScreamingDev commented 10 years ago

Same here but without setting rewrites.

My fixture:

eav:
  catalog_category:
    - entity_id: 21
      parent_id: 2
      path: 1/2/21
      name: Common
      level: 2
      children_count: 0
      is_active: 1
      /stores:
        1:
          name: Common

After the test that uses this UnitTest always breaks with the Integrity constraint violation.

    /**
     * Tests EveryProductHasSpecialLinksToManage.
     *
     * @loadFixture eav_catalog_category
     *
     * @registry    current_category
     * @registry    category
     */
    public function testEveryCategoryHasSpecialLinksToManage() {
        $this->dispatch('catalog/category/view', array('id' => 21));
    }

I see nothing wrong with the fixture neither with my test. core_url_rewrite is empty before and after running the test suite.