Adding custom registration attributes in Magento 1.7

I looked through web tutorials to add custom registration attributes to Magento. Although there are some solid tutorials, my favorite of them is: custom client registration attributes , but none of them have been updated for Magento 1.7.

Let me know if anyone has a tutorial that recommends or knows the steps necessary to add custom registration attributes in Magento 1.7.x.

I can say that I and many other developers will be very grateful, because this question was also posted on the Magento forums and documented in the Wiki, but, unfortunately, only for previous versions of Magento.

+2
source share
3 answers

you can run the following script from the root directory of magento, this attribute to add the attribute to the client and available to create the client and edit the client information, for example, I took 'mobile' here so that you can get this attribute using the getMobile() method in editing the client and creating a client page .... this script also automatically adds and displays in the 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(); 

Show attribute at the end of the font.

add the following code to the edit.phtml file located at application / design / interface / base / default / template / client / 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> 
+8
source

As your previous question, I think your link will only work with a lower version of magento

the link below will be very useful for adding a custom attribute to your registration process in 1.7

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

0
source

I am very happy to say that I was able to find a solution to my problem! After posting on the Magento forum and not getting an answer, I decided to dive in and decide for myself. I hope that my solution will help another Magento dev, which may encounter a similar problem.

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

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

3. After reading several other posts from Stack Exchange and the forum, I found that in this case Magneto is used by default for the database located in: app / design / frontend / base, with the register.phtml file located in / app / design / frontend /base/default/template/customer/form/register.phtml

4. Here you will understand that some of you may also work. Thinking that I understood this, I made changes to this file and ... nothing, no update on the interface. I tried flushing the caches, but that didn't work.

5. So, I continued to search and found that in my case (and possibly in yours!) The .phtml register is actually stored in / app / design / frontend / base / default / template / stable / client / form /

6. After editing this register.phtml file, I was in business

Hope this helps those of you facing this issue. Feel free to update this topic if you have any questions that help me a lot.

0
source

Source: https://habr.com/ru/post/1486141/


All Articles