Reputation: 1418
I've followed this tutorial exactly through step 2. I actually placed all of the files except those in the design directory that he has available for download into my app directory. Coincidentally, I am also trying to add the "school" attribute so so far I have not changed a thing. I see "school" in eav_attribute table. The module is listed as enabled in system>configuration>advanced>module output. I have reindexed and flushed cache, logged in and out. I still cannot see a "school" attribute when I try to edit a customer. I am using vs 1.7. Should this field be found in the "account information" tab for the customer? Is there anything outdated about this tutorial?
This is all in the code download, but for reference (he was missing the close of php tags, so I added those too): controllers/IndexController.php
<?php
class Excellence_Profile_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Profile>
<version>0.1.0</version>
</Excellence_Profile>
</modules>
<frontend>
<routers>
<profile>
<use>standard</use>
<args>
<module>Excellence_Profile</module>
<frontName>profile</frontName>
</args>
</profile>
</routers>
<layout>
<updates>
<profile>
<file>profile.xml</file>
</profile>
</updates>
</layout>
</frontend>
<admin>
<routers>
<profile>
<use>admin</use>
<args>
<module>Excellence_Profile</module>
<frontName>profile</frontName>
</args>
</profile>
</routers>
</admin>
<global>
<fieldsets>
<checkout_onepage_quote>
<customer_school>
<to_customer>school</to_customer>
</customer_school>
</checkout_onepage_quote>
<customer_account>
<school>
<to_quote>customer_school</to_quote>
</school>
</customer_account>
</fieldsets>
</global>
<global>
<fieldsets>
<customer_account>
<school><create>1</create><update>1</update><name>1</name></school>
</customer_account>
</fieldsets>
</global>
<global>
<models>
<profile>
<class>Excellence_Profile_Model</class>
<resourceModel>profile_mysql4</resourceModel>
</profile>
<profile_mysql4>
<class>Excellence_Profile_Model_Mysql4</class>
<entities>
<profile>
<table>profile</table>
</profile>
</entities>
</profile_mysql4>
</models>
<resources>
<profile_setup>
<setup>
<module>Excellence_Profile</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</profile_setup>
<profile_write>
<connection>
<use>core_write</use>
</connection>
</profile_write>
<profile_read>
<connection>
<use>core_read</use>
</connection>
</profile_read>
</resources>
<blocks>
<profile>
<class>Excellence_Profile_Block</class>
</profile>
</blocks>
<helpers>
<profile>
<class>Excellence_Profile_Helper</class>
</profile>
</helpers>
</global>
</config>
Model/Entity/School
<?php
class Excellence_Profile_Model_Entity_School extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = array();
$this->_options[] = array(
'value' => '',
'label' => 'Choose Option..'
);
$this->_options[] = array(
'value' => 1,
'label' => 'School1'
);
$this->_options[] = array(
'value' => 2,
'label' => 'School2'
);
$this->_options[] = array(
'value' => 3,
'label' => 'School3'
);
}
return $this->_options;
}
}
?>
Upvotes: 4
Views: 13218
Reputation: 1418
This answer helped me! Adding Custom Signup Attributes in Magento 1.7
@pragnesh
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 usinggetMobile()
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();
Upvotes: 6