0

Shop owner called telling me the gender select in the store contains Apple and Banana instead of male and female. Turns our this was the case in all form frondend/backend.

After some digging I found an extension with an mysql4-upgrade file. The only place I got any Apples, so this must be causing this problem:

$installer->addAttribute('catalog_product', 'p_layout', array(
             'label'             => 'Motiv',
             'type'              => 'varchar',
             'input'             => 'select',
             'backend'           => 'eav/entity_attribute_backend_array',
             'frontend'          => '',
             'source'            => '',
             'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
             'visible'           => true,
             'required'          => true,
             'user_defined'      => true,
             'searchable'        => false,
             'filterable'        => false,
             'comparable'        => false,
             'option'            => array (
                                            'value' => array(
                                                '1' => array('Apple'),
                                                '2' => array('Banana'),
                                            )
                                        ),
             'visible_on_front'  => false,
             'visible_in_advanced_search' => false,
             'unique'            => false
));

$attributeId = $installer->getAttributeId('catalog_product', 'p_layout');


if ($attributeId) {
    $option['attribute_id'] = $attributeId; //p_layout
    $option['value']['optionone'][0] = 'Apple';
    $option['value']['optionone'][1] = 'Apple';
    $option['value']['optionone'][2] = 'Apple';
    $option['value']['optionone'][3] = 'Apple';
    $option['value']['optiontwo'][0] = 'Banana';
    $option['value']['optiontwo'][1] = 'Banana';
    $option['value']['optiontwo'][2] = 'Banana';
    $option['value']['optiontwo'][3] = 'Banana';

    $installer->addAttributeOption($option);
    $installer->addAttributeSet('catalog_product', 'Stuff');

In eav_attribute_option_value I found option_id 1 and 2 being Apple and Banana. I guess during an update or the recent page move to another server this was overwritten.

Any idea how to fix this? I would like to avoid having this mess again...

Looks to pretty much like this: Upgrade script - Create new select attribute with options

Could the missing 'source' => 'eav/entity_attribute_source_table' causing this problem?

Or is '1' => array('Apple') the problem? I noticed in other places they set the value like this: array('Apple', 'Banana')

  • which magento version? Usually in System->Configuration->Customer Configuration you can define the prefixes by semicolon seperated values for "Prefix" – Peter Liebig Mar 3 '15 at 9:22
  • It is ce-1.7.0.2 and yes you can set Prefix Dropdown Options but not gender. There is only an option to Show Gender. I got that on optional but the values seem to be predefined in app/code/core/Mage/Customer/Model/Resource/Setup.php – PiTheNumber Mar 3 '15 at 9:28

Your Answer

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

Browse other questions tagged or ask your own question.