cancel
Showing results for 
Search instead for 
Did you mean: 

SOLVED: Problem Importing product price using Shell

SOLVED: Problem Importing product price using Shell

Product Prices index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magneto2`.`catalog_product_index_group_price`, CONSTRAINT `FK_CAT_PRD_IDX_GROUP_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`en)' in /home/public_html/magento2/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/public_html/magento2/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/public_html/magento2/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/public_html/magento2/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/public_html/magento2/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /home/public_html/magento2/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#5 /home/public_html/magento2/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#6 /home/public_html/magento2/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(498): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#7 /home/public_html/magento2/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(380): Mage_Catalog_Model_Resource_Product_Indexer_Price->_prepareGroupPriceIndex()
#8 /home/public_html/magento2/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexAll()
#9 /home/public_html/magento2/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#10 /home/public_html/magento2/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#11 /home/public_html/magento2/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#12 /home/public_html/magento2/shell/indexer.php(216): Mage_Shell_Compiler->run()
#13 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magneto2`.`catalog_product_index_group_price`, CONSTRAINT `FK_CAT_PRD_IDX_GROUP_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`en), query was: INSERT INTO `catalog_product_index_group_price` SELECT `gp`.`entity_id`, `cg`.`customer_group_id`, `cw`.`website_id`, MIN(IF(gp.website_id = 0, ROUND(gp.value * cwd.rate, 4), gp.value)) FROM `catalog_product_entity_group_price` AS `gp`
 INNER JOIN `customer_group` AS `cg` ON gp.all_groups = 1 OR (gp.all_groups = 0 AND gp.customer_group_id = cg.customer_group_id)
 INNER JOIN `core_website` AS `cw` ON gp.website_id = 0 OR gp.website_id = cw.website_id
 INNER JOIN `catalog_product_index_website` AS `cwd` ON cw.website_id = cwd.website_id WHERE (cw.website_id != 0) GROUP BY `gp`.`entity_id`,
        `cg`.`customer_group_id`,
        `cw`.`website_id` ON DUPLICATE KEY UPDATE `price` = VALUES(`price`)' in /home/public_html/magento2/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /home/public_html/magento2/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/public_html/magento2/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/public_html/magento2/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/public_html/magento2/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /home/public_html/magento2/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /home/public_html/magento2/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(498): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#6 /home/public_html/magento2/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(380): Mage_Catalog_Model_Resource_Product_Indexer_Price->_prepareGroupPriceIndex()
#7 /home/public_html/magento2/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexAll()
#8 /home/public_html/magento2/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#9 /home/public_html/magento2/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#10 /home/public_html/magento2/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#11 /home/public_html/magento2/shell/indexer.php(216): Mage_Shell_Compiler->run()
#12 {main}

Keep getting this error after importing products via MAgmi.

 

I have tried removing the var/locks folder. 

 

Checked my Spredsheets.

 

Used the database repair tool.

 

Any suggestiong would be greatly appreciated.

 

Alex 

1 REPLY 1

Re: Problem Importing product price using Shell

Problem Solved!

 

MAGMI has a new release for clearing catalog as there was a bug for Group Prices when removing it. 

 

Please check the Magmi Github and go under plugins/utlities/clearproducts and copy the php file to your magmi folder.

https://github.com/dweeves/magmi-git/tree/master/magmi/plugins/utilities/clearproducts

 

Also i have a problem when removing the catalog as it would set my root category to id 3 and my default is 2.

Here is a link to SQL Command to sort it.

http://www.imranulhoque.com/magento/reset-delete-magento-category-products-by-sql-for-magento-versio...