Magento で製品などを更新するために、外部サーバーからの json リクエストを使用しています (API を使用しなかった理由を尋ねないでください...)。属性情報を更新しようとしています。リソース抽象の _uniqueCheck() メソッドが失敗しているようです。問題は、それを修正する方法がわからないことです。次のコード
$attribute_model = Mage::getModel('eav/entity_attribute');
$attributeId = $attribute_model->getIdByCode('catalog_product', $attribute_code);
$attribute = $attribute_model->load($attributeId);
$attribute->setData($data)->save();
次のエラーが発生します。
[29-May-2013 16:32:00 UTC] PHP Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Attribute with the same code already exists.' in .../app/Mage.php:594
Stack trace:
#0 .../app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(676): Mage::throwException('Attribute with ...')
#1 .../app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(424): Mage_Core_Model_Resource_Db_Abstract->_checkUnique(Object(Mage_Eav_Model_Entity_Attribute))
#2 .../app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Eav_Model_Entity_Attribute))
#3 .../app/code/local/Valoran/Import/Model/Attribute.php(25): Mage_Core_Model_Abstract->save()
#4 .../app/code/local/Valoran/Harmony/Model/Messaging/Attributeset.php(115): Valoran_Import_Model_Attribute->_create(Array)
#5 .../app/code/local/Valoran/Harmony/Model/Messaging/Attributeset.php(23): Valoran_Harmony_Model_Messaging_Attribut in .../app/Mage.php on line 594
準備が整ったコードがすべて存在することを知っているので、これは私にとってイライラします.->load($id) ....
ここで私が見逃しているものについて何か考えている人はいますか? これを達成するために Mage_Eav_Model_Entity_Setup::updateAttribute メソッドを使用して調査していますが、これまでのところ同じエラーが発生しています。