0

Currently I am trying to add a customer attribute but getting the following error:

Fatal error: Class 'XXXXX_CustomerField_Model_Entity_Setup' not found in /app/code/core/Mage/Core/Model/Resource/Setup.php on line 234 Call Stack

Here is my module: local/XXXX/CustomerField/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <XXXX_CustomerField>
            <version>0.1.0</version>
        </XXXX_CustomerField>
    </modules>
    <global>
        <models>
            <XXXX_CustomerField>
                <class>Napit_CustomerField_Model</class>
            </XXXX_CustomerField>
        </models>
        <resources>
            <customerfield_setup>
                <setup>
                    <module>XXXX_CustomerField</module>
                <class>XXXX_CustomerField_Model_Resource_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </customerfield_setup>
        </resources>
        <fieldsets>
       <checkout_onepage_quote>
         <customer_membership_no>
             <to_customer>membership_no</to_customer>
         </customer_membership_no>
       </checkout_onepage_quote>
        <customer_account>
            <membership_no>
                <to_quote>customer_membership_no</to_quote>
            </membership_no>
        </customer_account>
      </fieldsets>
    </global>
</config>

local/XXXX/CustomerField/Model/Resource/Setup.php

<?php
class XXXX_CustomerField_Model_Resource_Setup extends Mage_Customer_Model_Entity_Setup 
{
    public function getDefaultEntities()
    {

        return array(

            'membership_no'=>array(
                    'type'=> 'static',
                    'label'=> 'Membership Number',
                    'visiable' => true,
                    'required' => false,
                    'sort_order' => 80,
            ),
        );
    }
}

and local/XXXX/CustomerField/sql/customerfield_setup/install-0.1.0.php

<?php

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

$installer->addAttribute('customer', 'membership_no', array(
    'label' => 'Membership Number',
    'visible' => 1,
    'required' => 0,
    'position' => 1,
    'sort_order' => 80,
));

$installer->endSetup();

$customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'membership_no');
$forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
$customer->setData('used_in_forms', $forms);
$customer->save();

Thanks

***** EDIT *****

So my problem was the folder path of was entity/setup where as it was calling resource/setup, I've made the amends now getting another error:

Fatal error: Call to a member function getColumns() on a non-object in lib/Varien/Db/Adapter/Pdo/Mysql.php on line 2201

  • 2
    please folder & file location – Amit Bera Sep 9 '15 at 14:27
  • Question Updated – Stefkay Sep 9 '15 at 14:35
  • Can you check the modules node it has only 3x – Dev Sep 9 '15 at 14:46
  • The node is correct ill update the question to add the extra "X" – Stefkay Sep 9 '15 at 14:47
  • Do you have the class file on the location 'XXXXX_CustomerField_Model_Entity_Setup' – Dev Sep 9 '15 at 14:59
1

Firstly I had config looking for entity_setup when my folder structure was resource_setup.

The next error came because I had to create an instance of Mage_Eav_Model_Entity_Setup this was done using:

$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
0

Please add bellow code in file : local/XXXX/CustomerField/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <XXXX_CustomerField>
            <version>0.1.0</version>
        </XXXX_CustomerField>
    </modules>
    <global>
        <models>
            <customerfield>
                <class>XXXX_CustomerField_Model</class>
            </customerfield>
        </models>
        <resources>
            <customerfield_setup>
              <setup>
                   <module>XXXX_CustomerField</module>
                   <class>Mage_Eav_Model_Entity_Setup</class>
              </setup>
          </customerfield_setup>
        </resources>
        <fieldsets>
       <checkout_onepage_quote>
         <customer_membership_no>
             <to_customer>membership_no</to_customer>
         </customer_membership_no>
       </checkout_onepage_quote>
        <customer_account>
            <membership_no>
                <to_quote>customer_membership_no</to_quote>
            </membership_no>
        </customer_account>
      </fieldsets>
    </global>
</config>

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.