You haven't mentioned which line the error occurs on, so I assume it's here:
$message = Mage::getModel('hwcustomer/message')
->setData($data) // <------------------- this line?
What does this mean?
It means that your call to retrieve the model with the alias
hwcustomer/message failed to resolve to a class name.
Mage_Core_Model_Config::getModelInstance() returns false if the class doesn't exist after it's alias is resolved.
How can I identify the problem?
Firstly, check that
hwcustomer/message is what you intended to write. If there's an obvious typo, stop reading now and fix it.
Using n98-magerun is a handy way to check if your model alias resolves correctly from the command line:
n98-magerun.phar dev:class:lookup model hwcustomer/message
If everything is OK, the above command should show your custom class name. If the class didn't resolve correctly or it doesn't exist, it will show an incorrect class name and/or that it doesn't exist.
Check the model exists
Firstly, you have to find where the model alias is defined. It's likely that this is a custom module that you've written (?) so you should know. If not, you need to find the module that defines something like this in its
Once you've found that:
<hwcustomer> tag is the first part of your model alias
<class> tag will tell you where to look for a class named
Message. Let's assume for argument's sake that your
<class> tag says
You'll either look for the model in
community if it's in the community pool.
Your model should exist and look something like this:
# File: app/code/local/Me/Hwcustomer/Model/Message.php
class Me_Hwcustomer_Model_Message extends Mage_Core_Model_Abstract
In the above example the
Message part of the filename is what is lowercased and used for the second half of the model alias
How do I fix it?
Ensure that all of the above configuration settings, file paths and file names check out correctly.
Other things to check
app/etc/modules/Me_Hwcustomer.xml (probably not called this, just an example) exists and the
<codePool> tag is correct (either local or community)
- Ensure that wherever the module's
<name> tag is used in XML, it is spelled correctly and that there are no upper or lowercased letters where there shouldn't be
- Ensure that you have cleared your cache. XML configuration is cached by default in Magento to reduce load time. If you change XML configuration values, you need to clear your cache.
Validating that the problem is fixed
Once you've found the problem and fixed it, you can test it quickly using n98-magerun again (the same command as provided earlier), and/or by running your process again.