0

i have tried to develop custom extension for adding new field in register customer field using below link

Register form field

app\etc\modules\Imorse_Mobile.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Imorse_Mobile>
            <active>true</active>
            <codePool>local</codePool>
            <depends><Mage_Customer/></depends>
        </Imorse_Mobile>
    </modules>
</config>

app\code\local\Imorse\Mobile\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Imorse_Mobile>
             <version>0.1.0</version>
        </Imorse_Mobile>
    </modules>

    <global>
        <helpers>
            <Imorse_Mobile>
                 <class>Imorse_Mobile_Helper</class>
            </Imorse_Mobile>
        </helpers>

        <resources>
            <Imorse_Mobile_setup>
                <setup>
                    <module>Imorse_Mobile</module>
                    <class>Mage_Customer_Model_Resource_Setup</class>
                </setup>
            </Imorse_Mobile_setup>
        </resources>

    </global>

    <frontend>
        <layout>
            <updates>   
                <Imorse_Mobile>
                    <file>Imorse_Mobile.xml</file>
                </Imorse_Mobile>
            </updates>  
        </layout>
         <translate>
            <modules>
                <Imorse_Mobile>
                    <files>
                         <default>Imorse_Mobile.csv</default>
                    </files>
                </Imorse_Mobile>
            </modules>
         </translate>
        <routers>
            <!-- <routeName> -->
                <customer>
                    <args>
                        <modules>
                            <Imorse_Mobile before="Mage_Customer_AccountController">Imorse_Mobile</Imorse_Mobile>
                        </modules>

                    </args>
                </customer>
            <!-- </routeName> -->
         </routers> 
    </frontend>

</config>

app\code\local\Imorse\Mobile\sql\Imorse_Mobile_setup\install-1.0.0.php

<?php
    $this->addAttribute('customer','mobile_number',array(
         'type'      => 'varchar',
        'label'     => 'Mobile Number',
        'input'     => 'text',
        'position'  => 120,
        'required'  => true,//or true
        'is_system' => 0,
    ));
    $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'mobile_number');

    $attribute->setData('used_in_forms', array(
        'adminhtml_customer',
        'checkout_register',
        'customer_account_create',
        'customer_account_edit',
    ));
    $attribute->setData('is_user_defined', 0);
    $attribute->save();


?>

But it is unable to store mobile number in db

Also try to extend controller app\code\local\Imorse\Mobile\controllers\AccountController.php

<?php 
    require 'Mage/Customer/controllers/AccountController.php';

    class Imorse_Mobile_AccountController extends Mage_Customer_AccountController{

        public function loginPostAction(){
            die("yes");
        }
    }
?>

But it always find the action in core controller, Please help me to solve this issue.

0

Update router code to this

<routers>
    <customer>
        <args>
            <modules>
                <Imorse_Mobile before="Mage_Customer">Imorse_Mobile</Imorse_Mobile>
            </modules>
        </args>
    </customer>
</routers> 
0

I think file name is wrong.

Change

app\code\local\Imorse\Mobile\etc\congix.xml

to

app\code\local\Imorse\Mobile\etc\config.xml

And update router xml code as follows

<routers>
    <customer>
        <args>
            <modules>
                <Imorse_Mobile before="Mage_Customer">Imorse_Mobile</Imorse_Mobile>
            </modules>
        </args>
    </customer>
</routers> 
  • thank youfor reply, the name of actual file is current. i have put it here wrong by mistake – Paritosh Mahale Apr 10 '17 at 13:15
  • Okay. I updated answer. Please check. – Kishan Patadia Apr 10 '17 at 13:23
0

Please use this code to solve your issue.

app/etc/modules/Imorse_Mobile.xml

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

app/code/local/Imorse/Mobile/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Imorse_Mobile>
      <version>0.1.0</version>
    </Imorse_Mobile>
  </modules>
  <global>
    <helpers>
      <mobile>
        <class>Imorse_Mobile_Helper</class>
      </mobile>
    </helpers>
    <models>
      <mobile>
        <class>Imorse_Mobile_Model</class>
        <resourceModel>mobile_mysql4</resourceModel>
      </mobile>
    </models>
    <resources>
      <customerattribute_setup>
        <setup>
          <module>Imorse_Mobile</module>
          <class>Mage_Customer_Model_Entity_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </customerattribute_setup>
      <customerattribute_write>
        <connection>
          <use>core_write</use>
        </connection>
      </customerattribute_write>
      <customerattribute_read>
        <connection>
          <use>core_read</use>
        </connection>
      </customerattribute_read>
    </resources>
  </global>
</config> 

app/code/local/Imorse/Mobile/Helper/Data.php

class Imorse_Mobile_Helper_Data extends Mage_Core_Helper_Abstract
{

}

app/code/local/Imorse/Mobile/sql/customerattribute_setup/mysql4-install-0.1.0.php

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


$installer->addAttribute("customer", "mobile_number",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Mobile Number",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => ""

    ));

$attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "mobile_number");


$used_in_forms=array();

$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
        $attribute->setData("used_in_forms", $used_in_forms)
        ->setData("is_used_for_customer_segment", true)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 1)
        ->setData("is_visible", 1)
        ->setData("sort_order", 100);
$attribute->save();



$installer->endSetup();

N.B : No need to override customer controller its a customer attribute.

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.