0

このエラーについて考えがありますか

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1421062-85-1-2' for key 1

製品(BOおよびFO)を保存しようとすると表示されます

4

2 に答える 2

1

ALTERTABLEコードの構文が間違っています。2つ欠落しています(最初の2行にあります。更新されました:

ALTER TABLE `catalog_product_entity_decimal` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_int`  ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);

/* Add unique keys to customer eav tables */
ALTER TABLE `customer_entity_decimal` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_int`  ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);

/* Add unique keys to customer address eav tables */
ALTER TABLE `customer_address_entity_decimal` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_int`  ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
于 2011-05-23T20:28:34.777 に答える
0

1.3 を 1.4 にアップグレードしたときに、これと同じ問題が発生しました。多くの重複エントリがあったことが判明しました (ええ、「それは彼女が言ったことです」)。解決策は、それらを見つけて排除することでした。それらを見つけるコードは次のとおりです。

SELECT `orig`.`entity_id`, 
   `orig`.`attribute_id`, 
   `orig`.`store_id`, 
   `orig`.`value` as `original_value`, 
   `duplicated`.`value` as `duplicated_value`
FROM `catalog_product_entity_decimal` as `orig` 
INNER JOIN `catalog_product_entity_decimal` as `duplicated` 
    ON (
         `orig`.`entity_id` = `duplicated`.`entity_id` 
         AND `orig`.`store_id` = `duplicated`.`store_id` 
         AND `orig`.`attribute_id` = `duplicated`.`attribute_id`
         AND `orig`.`value_id` > `duplicated`.`value_id`
   )

次に、一意のキーを追加します。

ALTER TABLE `catalog_product_entity_decimal` ADD UNIQUE KEY `IDX_BASE` `entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_int`  ADD UNIQUE KEY `IDX_BASE` `entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);
ALTER TABLE `catalog_product_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`);

/* Add unique keys to customer eav tables */
ALTER TABLE `customer_entity_decimal` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_int`  ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);

/* Add unique keys to customer address eav tables */
ALTER TABLE `customer_address_entity_decimal` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_int`  ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_varchar` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_text` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);
ALTER TABLE `customer_address_entity_datetime` ADD UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`);

そして、ジョナサンのコメントを考慮してください:)

于 2011-02-28T12:22:22.483 に答える