views:

24

answers:

1

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  A: 

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

Alan Storm
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.
Rakward
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
Rakward
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.
Janus Tøndering
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,
Rakward