We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Step 1: Create /app/code/local/Magemonkeys/Customerattribute/sql/magemonkeys_myattribute_setup/install-0.1.0.php file and add the following code in this file:

    <?php
    $installer = $this;
    
    $installer->startSetup();
    
    $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
    
    $entityTypeId     = $setup->getEntityTypeId('customer');
    $attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);
    $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
    
    $setup->addAttribute("customer", "myattribute",  array(
        "type"     => "varchar",
        "backend"  => "",
        "label"    => "My Attribute",
        "input"    => "text",
        "source"   => "",
        "visible"  => true,
        "required" => false,
        "default" => "",
        "frontend" => "",
        "unique"     => false,
        "note"       => "My Attribute"
    ));
    
    $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "myattribute");
    
    $setup->addAttributeToGroup(
        $entityTypeId,
        $attributeSetId,
        $attributeGroupId,
        'myattribute',
        '1000'
    );
    
    $usedIn=array();
    
    $usedIn[]="adminhtml_customer";
    $usedIn[]="checkout_register";
    $usedIn[]="customer_account_create";
    $usedIn[]="customer_account_edit";
    $usedIn[]="adminhtml_checkout";
            $attribute->setData("used_in_forms", $usedIn)
                    ->setData("is_used_for_customer_segment", true)
                    ->setData("is_system", 0)
                    ->setData("is_user_defined", 1)
                    ->setData("is_visible", 1)
                    ->setData("sort_order", 101)
                    ;
            $attribute->save();
    
    
    
    $installer->endSetup();
    ?>

    Step 2: Create /app/code/local/Magemonkeys/Customerattribute/etc/config.xml and add the following code in this file:

    <?xml version="1.0"?>
    <config>
    	<modules>
    		<Magemonkeys_Customerattribute>
    			<version>0.1.0</version>
    		</Magemonkeys_Customerattribute>
    	</modules>
    	<global>
    
    		<resources>
    			<Magemonkeys_Myattribute_setup>
    				<setup>
    					<module>Magemonkeys_Customerattribute</module>
    					<class>Mage_Customer_Model_Entity_Setup</class>
    				</setup>
    				<connection>
    					<use>core_setup</use>
    				</connection>
    			</Magemonkeys_Myattribute_setup>
    			<Magemonkeys_Myattribute_write>
    				<connection>
    					<use>core_write</use>
    				</connection>
    			</Magemonkeys_Myattribute_write>
    			<Magemonkeys_Myattribute_read>
    				<connection>
    					<use>core_read</use>
    				</connection>
    			</Magemonkeys_Myattribute_read>
    		</resources>
    	</global>
    
    </config>

    Step 3: Create app/etc/modules/Magemonkeys_Customerattribute.xml and add the following code in this file:

    <?xml version="1.0"?>
    <config>
    	<modules>
    		<Magemonkeys_Customerattribute>
    			<active>true</active>
    			<codePool>local</codePool>
    		</Magemonkeys_Customerattribute>
    	</modules>
    </config>

     

    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote