2

I have code like this :

    $setup->addAttribute('customer', 'my_custom_attr', array(
            "type" => "text",
            "backend" => "",
            "label" => "Languages for filter in layered filter.",
            "input" => "text",
            "source" => "",
            "visible" => false,
            "required" => false,
            "default" => "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",
            "frontend" => "",
            "unique" => false,
            "note" => "Imploded with comma array of language id's."
        )

attribute adds successfully but the default value is not avaliable for all existed entity:

    Mage::getModel('customer/customer')->getCollection()->getFirstItem()->getMyCustomAttr(); // null

but attribute exists, and i am able to update it, etc.

is it possible to set it as default or I need to update all existed records manually ?

I found this Set default value to custom attribute for all products but here it is Mage::getModel("catalog/product_action") model is used to update attributes, is there some way of doing it for customer entities ?

0

Please create attribute like below -

$setup->addAttribute('customer', 'your_attribute_code_here', array(
    'input'         => 'text', //or select or whatever you like
    'type'          => 'int', //or varchar or anything you want it
    'label'         => 'Attribute description goes here',
    'visible'       => 1,
    'required'      => 0, //mandatory? then 1
    'user_defined' => 1,
));

OR following working for me.

$installer = $this;
$installer->startSetup();

 $setup->addAttribute('customer', 'my_custom_attr', array(
            "type" => "text",
            "backend" => "",
            "label" => "Languages for filter in layered filter.",
            "input" => "text",
            "source" => "",
            "visible" => **true**,
            "required" => false,
            "default" => "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",
            "frontend" => "",
            "unique" => false,
            "note" => "Imploded with comma array of language id's."
        )
 $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "my_custom_attr");

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.