0

Suppose a product has five attributes. If you want to update one of the attributes, do you have to reference all existing attributes? Or will Magento remove attributes from the item if the attributes are not present in the array when you update the one attribute you are working with?

1

No. If you update only 1 attribute other will remain as it is.

For example: your product has attribute color and size.

  1. Color : black
  2. Size :small

If you update attribute color. Size will remian same.

If you pass attribute in array without value. it will remove selected option and will show blank.

This will be in all cases . Programmatically, import csv, and edit from admin.

  • Almost all cases** - if you use $product->addData(array $data) then it will override other data values. – Robbie Averill Oct 25 '16 at 0:53
  • @Robbie Averil . Sorry but I have mentioned if we pass attribute without value it will make value blank. And question is for update product attributes not for add value. Read question carefully. hope it will solved any doubt. – Kul Oct 25 '16 at 5:28
  • I have read the question carefully and suggested this as an amendment to your answer because your answer is misleading for others who might come across this question in future – Robbie Averill Oct 25 '16 at 5:29
  • Great but just make sure @t3chlay get proper solution – Kul Oct 25 '16 at 5:35
  • I'm using catalogProductUpdate to send the additional_attributes array with the associative pairs that hold the new values for the attributes. I don't know what function addData is. I'm using C# and looked around for a function called addData but couldn't find it. I believe I do understand what you were describing. Using update, only reference the attributes that you want to touch. Those will update and any others will remain the same. I would be interested to know the full name of the addData function call so that I can avoid it. – t3chlady Oct 25 '16 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.