1

When creating a product programmatically using the method described here, what format does the value need to be in for a Yes/No attribute type? (note: my attribute is global)

So far I have tried the following values for my Yes/No field:
0 and 1
1 and 2
'0' and '1'
'1' and '2'

So far all I am getting is the error "Invalid value for 'myAttributeName'"

I have scoured Google but somehow can't find an example of someone creating a product in this way where a Yes/No type attribute was used.

Note: I will test other values such as true false, 'Yes' 'No', and -1 0 and update question shortly.

1
  • 1
    You should be fine using true or false. Commented Apr 30, 2015 at 3:37

2 Answers 2

10

Well it turns out that the values need to be formatted as:
'Yes' or 'No' (including quotation marks / denoting a string)

Note:this is probably also dependant on the language being used for your store.

1
  • And this is on a default Magento product yes/no attribute or a select? BY the way, thank you for returning and answering your question Commented Apr 30, 2015 at 6:15
1

It is dependant to the language in Backend.

If the shop is in german language for example than the value has to be Ja or Nein.

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.