2013-08-23 67 views
1

得到以下錯誤:Magento的升級,獲得與一級價格從錯誤到1.4.0.2 1.7.0.2

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`catalog_product_entity_tier_price`, CONSTRAINT `FK_6E08D719F0501DD1D8E6D4EFF2511C85` FOREIGN KEY (`customer_group_id`) REFERENCES `customer_group` (`customer_group_id`) ON DEL) 

不知道如何解決這個問題。任何幫助?

當我檢查數據庫時,與其他任何magento安裝相同,customer_group有四行,其中catalog_product_entity_tier_price完全爲空。

customer_group錶轉儲:

CREATE TABLE IF NOT EXISTS `customer_group` (
`customer_group_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Customer Group Id', 
`customer_group_code` varchar(32) NOT NULL COMMENT 'Customer Group Code', 
`tax_class_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Tax Class Id', 
    PRIMARY KEY (`customer_group_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer Group' AUTO_INCREMENT=5 ; 

-- 
-- Dumping data for table `customer_group` 
-- 

INSERT INTO `customer_group` (`customer_group_id`, `customer_group_code`, `tax_class_id`) VALUES 
(1, 'General', 3), 
(2, 'Wholesale', 3), 
(3, 'Retailer', 3), 
(4, 'NOT LOGGED IN', 3); 

catalog_product_entity_tier_price轉儲:

-- 
-- Table structure for table `catalog_product_entity_tier_price` 
-- 

CREATE TABLE IF NOT EXISTS `catalog_product_entity_tier_price` (
    `value_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Value ID', 
    `entity_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity ID', 
    `all_groups` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Is Applicable To All Customer Groups', 
    `customer_group_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Customer Group ID', 
    `qty` decimal(12,4) NOT NULL DEFAULT '1.0000' COMMENT 'QTY', 
    `value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Value', 
    `website_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Website ID', 
PRIMARY KEY (`value_id`), 
UNIQUE KEY `E8AB433B9ACB00343ABB312AD2FAB087` (`entity_id`,`all_groups`,`customer_group_id`,`qty`,`website_id`), 
KEY `IDX_CATALOG_PRODUCT_ENTITY_TIER_PRICE_ENTITY_ID` (`entity_id`), 
KEY `IDX_CATALOG_PRODUCT_ENTITY_TIER_PRICE_CUSTOMER_GROUP_ID` (`customer_group_id`), 
KEY `IDX_CATALOG_PRODUCT_ENTITY_TIER_PRICE_WEBSITE_ID` (`website_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Tier Price Attribute Backend Table' AUTO_INCREMENT=4 ; 

-- 
-- Constraints for dumped tables 
-- 

-- 
-- Constraints for table `catalog_product_entity_tier_price` 
-- 
ALTER TABLE `catalog_product_entity_tier_price` 
    ADD CONSTRAINT `FK_6E08D719F0501DD1D8E6D4EFF2511C85` FOREIGN KEY (`customer_group_id`) REFERENCES `customer_group` (`customer_group_id`) ON DELETE CASCADE ON UPDATE CASCADE, 
    ADD CONSTRAINT `FK_CAT_PRD_ENTT_TIER_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE, 
    ADD CONSTRAINT `FK_CAT_PRD_ENTT_TIER_PRICE_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE; 

請幫我如何解決這個問題。 (使用magento 1.7.0.2)

謝謝。

回答

0

好的,挖了一個多小時後,我找到了原因。

customer_group table,NOT LOGGED INcustomer_group_id必須是0.但是在這個表中,它是4引起了這個問題。

將id更改爲0時,它現在工作正常。