Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Page 1 of 2
Problem with generation of flat catalog product
 
ryu007
Sr. Member
 
Total Posts:  273
Joined:  2008-03-24
France, Paris
 

Good evening,

This time, my magento’s update was rather pretty good.

But when I want to generate the flat catalog product, I meet a foreign key problem :

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 (`artbambo/catalog_product_flat_1`, CONSTRAINT `FK_CATALOG_PRODUCT_FLAT_1_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE)’ in /home/artbambou/www/lib/Zend/Db/Statement/Pdo.php:238 Stack trace: #0 /home/artbambou/www/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 /home/artbambou/www/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array) #2 /home/artbambou/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(’INSERT INTO `ca...’, Array) #3 /home/artbambou/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(259): Zend_Db_Adapter_Pdo_Abstract->query(’INSERT INTO `ca...’, Array) #4 /home/artbambou/www/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(749): Varien_Db_Adapter_Pdo_Mysql->query(’INSERT INTO `ca...’) #5 /home/artbambou/www/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(120): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->updateRelationProducts(’1’) #6 /home/artbambou/www/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(108): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->rebuild(’1’) #7 /home/artbambou/www/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php(235): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->rebuild() #8 /home/artbambou/www/app/code/core/Mage/Core/Controller/Varien/Action.php(367): Mage_Adminhtml_System_CacheController->saveAction() #9 /home/artbambou/www/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(247): Mage_Core_Controller_Varien_Action->dispatch(’save’) #10 /home/artbambou/www/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #11 /home/artbambou/www/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch() #12 /home/artbambou/www/index.php(52): Mage::run() #13 {main}

I have looked for the matching foreign key : FK_CATALOG_PRODUCT_FLAT_1_ENTITY but I didn’t find it.
Some help are very appreciated.

Regards,
Ilan

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
elitriona
Sr. Member
 
Total Posts:  105
Joined:  2008-10-23
 

I have the same problem when trying to Rebuild Flat Catalog Product.

Additionally, if I try to Rebuild Flat Catalog Category it generates a rather nondescript error message in a red box at the top that says “Flat Catalog Category rebuild error” and that’s it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryu007
Sr. Member
 
Total Posts:  273
Joined:  2008-03-24
France, Paris
 

I have looked everything so far, and I didn’t find any solution yet!

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryu007
Sr. Member
 
Total Posts:  273
Joined:  2008-03-24
France, Paris
 

Temporary fix :
Edit /app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php

L440 :
Replace

$sql .= "  CONSTRAINT `FK_CATALOG_PRODUCT_FLAT_{$store}_ENTITY` FOREIGN KEY (`entity_id`)"
                
" REFERENCES `{$this->getTable('catalog/product')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n"
                
"  CONSTRAINT `FK_CATALOG_PRODUCT_FLAT_{$store}_CHILD` FOREIGN KEY (`child_id`)"
                
" REFERENCES `{$this->getTable('catalog/product')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE\n"
                
") ENGINE=InnoDB DEFAULT CHARSET=utf8";

By

$sql substr($sql0, -2);
            
$sql .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8";

Only now, the flat catalog product is not anymore updated when you delete or update a product…

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jimhoyd
Jr. Member
 
Total Posts:  10
Joined:  2008-12-11
 

I have encountered the same problem

exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘’ for key 2’ in /var/app/magento/lib/Zend/Db/Statement/Pdo.php:238 Stack trace: #0 /var/app/magento/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 /var/app/magento/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array) #2 /var/app/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(’UPDATE `catalog...’, Array) #3 /var/app/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(259): Zend_Db_Adapter_Pdo_Abstract->query(’UPDATE `catalog...’, Array) #4 /var/app/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(637): Varien_Db_Adapter_Pdo_Mysql->query(’UPDATE `catalog...’) #5 /var/app/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(655): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->updateAttribute(Object(Mage_Catalog_Model_Resource_Eav_Attribute), ‘4’, NULL) #6 /var/app/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(118): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->updateEavAttributes(’4’) #7 /var/app/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Flat/Indexer.php(108): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->rebuild(’4’) #8 /var/app/magento/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php(235): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat_Indexer->rebuild() #9 /var/app/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(367): Mage_Adminhtml_System_CacheController->saveAction() #10 /var/app/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(247): Mage_Core_Controller_Varien_Action->dispatch(’save’) #11 /var/app/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #12 /var/app/magento/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch() #13 /var/www/furoshiki.com/public/index.php(55): Mage::run(’furoshiki’) #14 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Bové
Member
 
Total Posts:  57
Joined:  2008-08-26
 

I have the same problem as hoyd

anyone a solution

 
Magento Community Magento Community
Magento Community
Magento Community
 
avintel
Sr. Member
 
Total Posts:  146
Joined:  2008-05-15
Southern California
 

what is this so called flat product? any place i can find info that gives a good and thorough explanation?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jimhoyd
Jr. Member
 
Total Posts:  10
Joined:  2008-12-11
 

for me I think it is failing while creating the catalog_product_flat_n, tables

btw, I am running a multistore

in app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Product\Flat\Indexer.php

on line 392, it fails

something about,

if (!$this->_getWriteAdapter()->fetchRow($tableExistsSql)) {

 
Magento Community Magento Community
Magento Community
Magento Community
 
hridaya
Member
 
Avatar
Total Posts:  63
Joined:  2009-02-04
Nepal
 

I found this error when trying to Rebuild Flat Catalog Product.

SELECT SUM(order_items.qty_ordered) AS `ordered_qty`, `e`.*, `e`.`entity_id`, `e`.`child_id`, `e`.`is_child`, `e`.`attribute_set_id`, `e`.`type_id`, `e`.`category_ids`, `e`.`color`, `e`.`color_value`, `e`.`computer_manufacturers`, `e`.`computer_manufacturers_value`, `e`.`contrast_ratio`, `e`.`contrast_ratio_value`, `e`.`description`, `e`.`enable_googlecheckout`, `e`.`engravings`, `e`.`hard_drive_size`, `e`.`has_options`, `e`.`image`, `e`.`image_label`, `e`.`links_purchased_separately`, `e`.`links_title`, `e`.`manufacturer`, `e`.`manufacturer_value`, `e`.`megapixels`, `e`.`megapixels_value`, `e`.`mto_depth_max`, `e`.`mto_depth_min`, `e`.`mto_depth_step`, `e`.`mto_height_max`, `e`.`mto_height_min`, `e`.`mto_height_step`, `e`.`mto_width_max`, `e`.`mto_width_min`, `e`.`mto_width_step`, `e`.`myorder_customercomment`, `e`.`my_comment`, `e`.`name`, `e`.`price`, `e`.`price_type`, `e`.`price_view`, `e`.`required_options`, `e`.`samples_title`, `e`.`shape`, `e`.`shipment_type`, `e`.`shoe_type`, `e`.`shoe_type_value`, `e`.`short_description`, `e`.`sku`, `e`.`small_image`, `e`.`small_image_label`, `e`.`special_from_date`, `e`.`special_price`, `e`.`special_to_date`, `e`.`tax_class_id`, `e`.`thumbnail`, `e`.`thumbnail_label`, `e`.`url_key`, `e`.`url_path`, `e`.`weight`, `e`.`weight_type`, `e`.`display_price_group_0`, `e`.`display_price_group_1`, `e`.`display_price_group_2`, `e`.`display_price_group_3`, `e`.`display_price_group_4` FROM `sales_flat_order_item` AS `order_items`
INNER JOIN `sales_order` AS `order` ON order.entity_id = order_items.order_id
INNER JOIN `sales_order_varchar` AS `order_state` ON order.entity_id = order_state.entity_id AND order_state.attribute_id=’553’ AND order_state.value<>’canceled’
INNER JOIN `catalog_product_entity` AS `e` ON e.entity_id = order_items.product_id AND e.entity_type_id = 10 AND (e.type_id NOT IN (’grouped’, ‘configurable’, ‘bundle’)) GROUP BY `e`.`entity_id` HAVING (ordered_qty > 0) ORDER BY `ordered_qty` desc LIMIT 6

Trace:
#0 C:\xampp\htdocs\magento\lib\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\xampp\htdocs\magento\lib\Zend\Db\Adapter\Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 C:\xampp\htdocs\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query(’SELECT SUM(orde...’, Array)
#3 C:\xampp\htdocs\magento\lib\Varien\Db\Adapter\Pdo\Mysql.php(259): Zend_Db_Adapter_Pdo_Abstract->query(’SELECT SUM(orde...’, Array)
#4 C:\xampp\htdocs\magento\lib\Zend\Db\Adapter\Abstract.php(668): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#5 C:\xampp\htdocs\magento\lib\Varien\Data\Collection\Db.php(761): Zend_Db_Adapter_Abstract->fetchAll(Object(Varien_Db_Select), Array)
#6 C:\xampp\htdocs\magento\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(933): Varien_Data_Collection_Db->_fetchAll(Object(Varien_Db_Select))
#7 C:\xampp\htdocs\magento\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(783): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false)
#8 C:\xampp\htdocs\magento\app\code\local\Luxe\Bestsellers\Block\List.php(82): Mage_Eav_Model_Entity_Collection_Abstract->load()
#9 C:\xampp\htdocs\magento\app\code\core\Mage\Catalog\Block\Product\List.php(130): Luxe_Bestsellers_Block_List->_getProductCollection()
#10 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php(642): Mage_Catalog_Block_Product_List->_beforeToHtml()
#11 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Email\Template\Filter.php(74): Mage_Core_Block_Abstract->toHtml()
#12 C:\xampp\htdocs\magento\lib\Varien\Filter\Template.php(128): Mage_Core_Model_Email_Template_Filter->blockDirective(Array)
#13 C:\xampp\htdocs\magento\app\code\core\Mage\Cms\Block\Page.php(80): Varien_Filter_Template->filter(Array, Array)
#14 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Block\Abstract.php(643): Mage_Cms_Block_Page->_toHtml(’

 Signature 

http://hridaya.com.np

 
Magento Community Magento Community
Magento Community
Magento Community
 
mediagang
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2008-01-17
Leeds UK
 

Hridaya. I had the same problem.  Fixed it by reinstalling 1.3.0 , set Use Flat Catalog Category and Use Flat Catalog Product to no. cleared cache.

Would still like to know why i get this error?

 Signature 

UK Magento Services
Solar Gadget Store : Catering Equipment : Guerrilla Marketing

 
Magento Community Magento Community
Magento Community
Magento Community
 
zmove
Guru
 
Total Posts:  316
Joined:  2008-04-30
 

Hmmmm

And when this error comes in a production environment ? :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
spectrumaudio
Member
 
Total Posts:  32
Joined:  2008-07-22
 

I am having the same problem as Hridaya and getting the same error message. Does anyone have a fix for this? I would love to be able to Use Flat Catalog Product in 1.3.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
phingers
Jr. Member
 
Total Posts:  1
Joined:  2010-05-19
 

I have the same issue.

catalog_product_flat_1 is empty?

Anyone figure this out?

 
Magento Community Magento Community
Magento Community
Magento Community
 
wsj3
Guru
 
Avatar
Total Posts:  518
Joined:  2008-07-13
Portland, OR
 

Did anyone ever discover a fix for this?

 Signature 

Will Johnston
http://www.growandmake.com
The Store for Sustainable Living

 
Magento Community Magento Community
Magento Community
Magento Community
 
wsj3
Guru
 
Avatar
Total Posts:  518
Joined:  2008-07-13
Portland, OR
 

Can someone tell me if the fixed this? I’m trying to determine if disabling foreign key constraints will fix this? Is there an option with the uprade for not enabling flat product catalog, which might have created this error?

Any help would really be appreciated here.

 Signature 

Will Johnston
http://www.growandmake.com
The Store for Sustainable Living

 
Magento Community Magento Community
Magento Community
Magento Community
 
antaldagmia
Jr. Member
 
Total Posts:  1
Joined:  2011-03-09
 

Hi,

I know this is an old post but i will reply here with the solution just in case:

This table is automatically Generated by magento when you Reindex the “Product Flat Data” Index so Here’s what you have to do:

1) Go into phpmyadmin or access mysql daemon via ssh
2) Change the name of the table catalog_product_flat_1 to something like catalog_product_flat_OLD_1 (just for backup)
3) Reindex Product Flat Data in your Magento Admin Panel
4) Thanks me for the solution

Regards

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2
 
© Copyright 2012 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
704029 users|1760 users currently online|497345 forum posts