I created a custom Yes/No attribute for products and assigned it to default attribute group. I have to save value of Yes/No attribute programmatically. is it possible? if Yes, How can I manage product value programmatically?

2 Answers 2


Use this if you dont want to save the whole product. Its much faster.

$productObj->setData('attribute_code', 1); //$value = 1 for yes and $value = 0 for No.
$productObj->getResource()->saveAttribute($productObj, 'attribute_code');
  • Thanks kingshuk, Do you have any idea of getData from custom attribute ? Commented Apr 24, 2017 at 7:26
  • $productObj->getAttributeCode(); Do you mean this? Commented Apr 24, 2017 at 7:30
  • Let me check this one Commented Apr 24, 2017 at 7:31
  • not its not working for me, i am not able to get attribute like this. Commented Apr 24, 2017 at 9:50
  • Probably that attribute has no value assigned yet. Either set it to YES or No then save the product and check on frontend. You should be able to get it. Commented Apr 24, 2017 at 9:57

You can set it like:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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