Update custom product attribute values - Magento -
I have problems with updating table catalog / product in Magento I want to update price in '' custom_product_option '' Which I have added as an EAV attribute:
for ($ i = 0; $ i & lt; = sizeof ($ my_data); $ i ++) {$ id = $ My_data [$ i]; $ Db_data = array ('custom_product_option' => 3); $ Model = Dana :: MillModel ('catalog / product') - & gt; Load ($ ID) - & gt; Adadata ($ db_data); {$ Model-> tryId ($ id) - & gt; Save (); The echo "The data was updated successfully."; } Hold (exception $ e) {echo $ e-> GetMessage (); }}
When I try to update my new custom value in the list / product table, I get this error:
Integrity barrier violation 1062 Duplicate entry '44 -1-0-2.0000-0 'for key' ... '
I am confused, because I am updating the table, and this behavior As I am putting a new value with the same ID. I appreciate it that someone can help.
I think the $ my_data is an array of product IDs Which needs to be updated.
If so, then try it very fast:
$ db_data = array ('custom_product_option' => 3); Mage :: getSingleton ('catalog / product_action') - & gt; UpdateAttributes ($ my_data, // array with ID to update, $ db_data, // array with properties to update, 0 // store id: 0 = default value for updates);
Comments
Post a Comment