Magento SQLSTATE error if there is one item left in product inventory

China☆狼群 提交于 2019-12-02 07:39:28

We used to have a similar problem on magento 1.7, it happened because we introduced a "new" type of product that is a bundle of configurable products. In this case we had some products that were at the same time parent of some products and children of some other (the bundle ones) that way when _copyRelationIndexData was called by reindexProductIds catalog_product_index_price_tmp table was filled with some rows belonging to "composite products" causing the "Integrity constraint violation" when reindexEntity is called. Long story short we overrode _copyRelationIndexData method this way :

protected function _copyRelationIndexData($parentIds, $excludeIds = null)
    {
        if(!is_null($excludeIds) && is_array($excludeIds)){
            $excludeIds = array_merge($excludeIds,$parentIds);
        }
        return parent::_copyRelationIndexData($parentIds, $excludeIds);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!