Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set default store view label using my attribute script in magento

I am using a module to create a new attribute on the customer model. Does anyone know how to set the default store view using my setup script?

admin screenshot

My current script:

$setup = new Mage_Customer_Model_Resource_Setup('customer_setup');

if (! $setup->getAttribute('customer', 'dob_month')) {
    $setup->addAttribute('customer', 'dob_month', array(
        'label'     => 'Month',
        'type'      => 'varchar',
        'input'     => 'select',
        'source'    => 'eav/entity_attribute_source_table',
        'required'  => true,
        'position'  => 1,
        'option'    => array (
            'values' => array (
                'January',
                'February',
                'March',
                'April',
                'May',
                'June',
                'July',
                'August',
                'September',
                'October',
                'November',
                'December'
            )
        )
    ));
}
like image 796
Scott S Avatar asked Jan 15 '23 13:01

Scott S


1 Answers

As far as I know it is impossible to do this directly in the addAttribute() call. But you can set store labels after saving attribute in the next way:

$attributeId = $this->getAttributeId('customer', 'dob_month');
$attribute = Mage::getModel('eav/entity_attribute')->load($attributeId);
$attribute->setStoreLabels(array(store_id => 'Store label'))
    ->save();
like image 104
Dmytro Zavalkin Avatar answered Jan 30 '23 09:01

Dmytro Zavalkin