Adding Custom Signup Attributes in Magento 1.7

前端 未结 3 753
梦毁少年i
梦毁少年i 2021-02-06 19:07

I have scoured the web for tutorials for adding custom signup attributes in Magento. While there are a few solid tutorials out there, my favorite being this one: custom customer

相关标签:
3条回答
  • 2021-02-06 19:12

    As your above question i think your link will work only lower version of magento

    below link would be very use full to add custom attribute to your sign up process in 1.7

    use [customer-registration-fields-magento][1]

    0 讨论(0)
  • 2021-02-06 19:14

    I am very happy to say that I have been able to find a solution to my problem! After posting on the Magento forum and not getting a response I decided to dive in and solve this for myself. I am hoping that my solution will help other Magento dev's that might be experiencing a similar problem.

    1. I found the following tutorial which was incredibly helpful: http://www.magentocommerce.com/wiki/5_-_modules_and_development/customers_and_accounts/registration_fields

    2. Unfortunately my theme did not have the register.phtml file located in: app/design/frontend/default/yourtheme/template/customer/form/

    3. After reading a few other Stack Exchange and forum posts I found that in this case Magneto default's to the base located in: app/design/frontend/base with the register.phtml file located at /app/design/frontend/base/default/template/customer/form/register.phtml

    4. Here's the catch that some of you also might be running into. After thinking I had figured it out, I made changes to this file and...nothing, no update on the frontend. I tried flushing the caches but it didn't work.

    5. So I kept searching and found that in my case (and potentially in yours!) the register.phtml is actually stored under /app/design/frontend/base/default/template/persistent/customer/form/

    6. After editing that register.phtml file I was in business

    I hope this helps those of you who are running into this same issue. Feel free to update this thread if you have any questions, happy to help in any way that I can.

    0 讨论(0)
  • 2021-02-06 19:21

    you can run following script from magento root directory, this scipt add attribute to customer and accessible in create customer and edit customer detail, example i have taken 'mobile' here so you can get that attribute using getMobile() method in edit customer and create customer page.... this script also automatically add and display in admin panel try these..

    define('MAGENTO', realpath(dirname(__FILE__)));
    
    require_once MAGENTO . '/app/Mage.php';
    
    Mage::app();
    
    
    
    $installer = new Mage_Customer_Model_Entity_Setup('core_setup');
    
    $installer->startSetup();
    
    $vCustomerEntityType = $installer->getEntityTypeId('customer');
    $vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
    $vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);
    
    $installer->addAttribute('customer', 'mobile', array(
            'label' => 'Customer Mobile',
            'input' => 'text',
            'type'  => 'varchar',
            'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
            'required' => 0,
            'user_defined' => 1,
    ));
    
    $installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'mobile', 0);
    
    $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'mobile');
    $oAttribute->setData('used_in_forms', array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'));
    $oAttribute->save();
    
    $installer->endSetup();
    

    Display attribute on Font End.

    add following code to edit.phtml file located at app/design/frontend/base/default/template/customer/form/edit.phtml

    <li>
         <label class="required"><?php echo $this->__('Mobile') ?><em>*</em></label>
    </li>
    <li>
         <input type="text" value="<?php echo $this->getCustomer()->getMobile(); ?>" title="<?php echo $this->__('Mobile') ?>" name="mobile" class="input-text validate-digits-range digits-range-1000000000-9999999999 required-entry">
    </li>
    
    0 讨论(0)
提交回复
热议问题