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
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 ? Apr 24, 2017 at 7:26
-
-
-
not its not working for me, i am not able to get attribute like this. 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. Apr 24, 2017 at 9:57