0

I'm creating a module that let's you define some extra options for categorys in Magento, following this tuturial to get started: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module

I built on a skeleton module created with ModuleCreator.

I have created Setup.php (with the capital) in Infoweb/Margins/Model/Resource/Eav/Mysql4/ and in it my class defined:

class Infoweb_Margins_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup{}

I also added this line in my config.php(the rest was already there because of the skeleton module):

<class>Infoweb_Margins_Resource_Eav_Mysql4_Setup</class>

Now when trying to load a page, magento searches for this class but gives a fatal error saying the class was not found ... Error: Fatal error: Class 'Infoweb_Margins_Resource_Eav_Mysql4_Setup' not found in /home/users/A000456/xxx/xxx/app/code/core/Mage/Core/Model/Resource/Setup.php on line 160

Thoughts on where the problem lies?

Using Magento 1.4.1.0

1 Answer 1

1

Magento is complaining that it can't find your class

Infoweb_Margins_Resource_Eav_Mysql4_Setup

this is actually semi-good news. The fact that Magento knew to look for a class with the prefix Infoweb_Margins means you have your XML setup correctly.

The problem is your class name. Magento's auto loader only* knows how to handle class in the form

Packagename_Modulename_Model_*
Packagename_Modulename_Helper_*
Packagename_Modulename_Block_*

your class is named

Infoweb_Margins_Resource_*

which Magento doesn't know what to do with.

If you've placed a file named Setup.php at

Infoweb/Margins/Model/Resource/Eav/Mysql4/

you want a class named

Infoweb_Margins_Model_Resource_Eav_Mysql4_Setup

Change that in your XML and class definition and you should be set

* this might be a semi-fib, I haven't peeked at Magento's __autoloader in a while

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, but I have 1 more question, how do I re-install the module? I only got it to add the attributes after importing an older database and then refreshing. Disabling the module didn't do it and I have all caches disabled.
Also, I can't get SCOPE_STORE to work, I can only add GLOBAL options(no checkbox on store view) :( I really need to be able to set an attributes per store
Delete your module from the core_resources (if my memoery serves me right) table in the database. Magento will then re-run the install logic. You could also bump the version number.
Thank you, any idea about how to get SCOPE_STORE or SCOPE_WEBSITE to work? Currently using: 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.