Magento1 adding custom properties to customer customer orientation customer Journey Map Customer BAS

Source: Internet
Author: User
Data-id= "1190000005008696" data-license= "CC" >

In the SQL file of the module:
/**

    • ADD Attribute Mobile for customer
      */

 //echo 12345; $installer = $this; $installer->startsetup (); $eavConfig = Mage::getsingleton (' eav/config '); $store = Mage::app ()->getstore (mage_core_model_app::admin_store_id); $         SortOrder = 999; $attributes = Array (' chuanzhen ' = = Array (' type ' = ' = ' varchar ', ' label ' = ' chuanzhen ', ' input ' = ' text ', ' required ' + 1, ' global ' = 1, ' Is_ Visible ' + 1, ' is_system ' = 0, ' position ', ' is_user_defined ' and ' 1 ', ' Sort_orde R ' = + $sortOrder + +,), ' sex ' = = Array (' type ' = ' = ' int ', ' label ' = = ') Sex ', ' input ' = ' radio ', ' required ' = 1, ' is_visible ' and ' 1, ' Is_system ' and 0 , ' global ' = 1, ' is_user_defined ' and ' 1, ' position ', ' sort_order ' and $sortOr der++,),  

);
/ to save the above attribute to the database and add it to the page form /

foreach ($attributes as $attributeCode = + $data) {$installer->addattribute (' Customer ', $attributeCode, $data);} foreach ($attributes as $attributeCode = = $data) {$attribute = $eavConfig->getattribute (' Customer ', $attributeCo    DE);    $attribute->setwebsite ($store->getwebsite ());    $attribute->adddata ($data); if (false = = = ($data [' is_system '] = = 1 && $data [' is_visible '] = = 0)) {$usedInForms = Array (' CU Stomer_account_create ', ' customer_account_edit ', ' checkout_register ', ' Adminhtml_customer        ', ' adminhtml_checkout ');    $attribute->setdata (' used_in_forms ', $usedInForms); } $attribute->save ();}    $installer->endseup (); Add the properties of the drop-down box, add the gender male and Famale: $installer->startsetup (); $installer->addattribute (' Customer ', ' Gender ', Array (' label ' = ' gender ', ' visible ' = = Tru E, ' required ' = False, ' type ' = ' int ', ' input ' = ' select ', ' source ' = ' eav/entity_attribute_source_table ',));   
$tableOptions        = $installer->getTable('eav_attribute_option');  $tableOptionValues   = $installer->getTable('eav_attribute_option_value');    // add options for level of politeness  $attributeId = (int)$installer->getAttribute('customer', 'gender', 'attribute_id');  foreach (array('Male', 'Female') as $sortOrder => $label) {    // add option  $data = array(    'attribute_id' => $attributeId,      'sort_order'   => $sortOrder,  );  $installer->getConnection()->insert($tableOptions, $data);  // add option label  $optionId = (int)$installer->getConnection()->lastInsertId($tableOptions, 'option_id');  $data = array(      'option_id' => $optionId,      'store_id'  => 0,      'value'     => $label,  );  $installer->getConnection()->insert($tableOptionValues, $data);  

}

$installer->endSetup();

The above describes the magento1 to the customer to add custom attributes, including the customer,magento aspects of the content, I hope that the PHP tutorial interested in a friend to help.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.