Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove initial empty value for a dropdown attribute in Magento?

I'm using Magento version 1.5.1.0. I added an attribute with the following options selected in the Properties tab:

Catalog input type for store owner: dropdown
Unique value: no
Values required: no

I then went to the Manage Label/Options tab and added 3 different options, selecting the first option as a default. I added it to an attribute set, and when I go to enter a product, I see the dropdown, but with an empty option value prepended to it:

<select>
    <option selected="selected"></option>
    <option>Option 1</option>
    <option>Option 2</option>
    <option>Option 3</option>
</select>

When I save the product, the empty option still remains selected. How do I remove that empty option and make Option 1 the default for all of my existing products without resorting to using JS or editing any files whatsoever?

like image 747
danronmoon Avatar asked Jul 24 '12 14:07

danronmoon


1 Answers

I think this can help.

When you call getAllOptions you need to pass false.

->getAllOptions(false)

Magento attribute dropdown with first empty value

like image 123
Xus Avatar answered Nov 15 '22 01:11

Xus