Magento – Source model not found for attribute “specialist”

customercustomer-attributemagento-1.9PHP

I was created "specialist" as custom customer attribute,while my development time it was working fine, now i move the files to server and doing the optimization(catch enable, compilation and etc..).

Now the front end is showing error "Source model "Federallawyer_Customer_Model_Entity_specialist" not found for attribute "specialist" ",

May i know what is the solution to rectify the problem, thanks in advance for your idea and help.

enter image description here

Code for add new attribure

$this->addAttribute('customer', 'specialist', array(
    'type'      => 'int',
    'label'     => 'Practice Area',
    'input'     => 'multiselect',
    'global' => true,
    'visible' => true,
    'required' => false,
    'user_defined' => false,
    'source' => 'Federallawyer_Customer_Model_Entity_specialist',
));
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'specialist');
$attribute->setData('used_in_forms', array(
    'adminhtml_customer',
    'customer_account_edit',
));
$attribute->setData('is_user_defined',1);
$attribute->save();

Best Answer

Maybe, problem is in the name of class, you need to use 'Federallawyer_Customer_Model_Entity_Specialist' instead of 'Federallawyer_Customer_Model_Entity_specialist' ? And always You ought to check resources models for attributes:

protected function _getAttributeOptions($attributeCode)
{
    if ($attributeCode) {

        /** @var Mage_Customer_Model_Attribute $attribute*/
        $attribute = Mage::getModel('eav/config')->getAttribute('customer', $attributeCode);
        $options = [];
        if ($attribute->usesSource()) {
            try {

                /** @var Mage_Eav_Model_Entity_Attribute_Source_Table $source */
                $source = $attribute->getSource();
                if ($source) {
                    foreach ($source->getAllOptions(false, true) as $option) {
                        $options[$option['value']] = $option['label'];
                    }

                    return $options;
                }
            } catch (Exception $e) {
                Mage::logException($e->getMessage());
            }
        }
    }

    return [];
}
Related Topic