Hi I'm creating column/field for Customer Activate which is option column/field. it's created from eva_attribute
and showing customer admin grid also when I click on edit particular customer record it's returning an error.
Error is: Source model "customer/source_option" not found for attribute "customeractivate"
my code is:
C:\xampp\htdocs\magento\app\code\local\Easylife\Customattribute\sql\customattribute_setup\upgrade-0.1.1-0.1.2.php
<?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', 'customeractivate', array(
'label' => 'Customer Activate',
'type' => 'int',
'input' => 'select',
'backend' => 'eav/entity_attribute_backend_array',
'frontend' => '',
'source' => 'customer/group_collection',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => true,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'option' => array ('value' => array('optionone' => array('Yes'),
'optiontwo' => array('No'),)),
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false
));
$setup = Mage::getSingleton("eav/config")->getAttribute("customer", "customeractivate");
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$setup->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)
;
$setup->save();
$installer->endSetup();
C:\xampp\htdocs\magento\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php
<?php
class Mage_Adminhtml_Block_Customer_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
...
protected function _prepareColumns()
{
$this->addColumn('customeractivate',
array(
'header'=> Mage::helper('customer')->__('Customer Active'),
'width' => '70px',
'index' => 'status',
'type' => 'options',
'options' => Mage::getResourceModel('customer/group_collection')->getOptionArray(),
));
}
..
}
C:\xampp\htdocs\magento\app\code\core\Mage\Customer\Model\Resource\Group\Collection.php
<?php
class Mage_Customer_Model_Resource_Group_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 2;
...
static public function getOptionArray()
{
return array(
self::STATUS_ENABLED => Mage::helper('customer')->__('Yes'),
self::STATUS_DISABLED => Mage::helper('customer')->__('No')
);
}
...
}
Can you please tell me where I went wrong?
thanks in advance.
'type' => 'option'
should be'type' => 'int'
or'type' => 'varchar'
. Probablyint
.customer/group_collection
not found for attributecustomeractivate
.resource
folder. Based on the values you set for the attribute, magento is looking for the class inMage_Customer_Model_Group_Collection