When I use the below code for updating store credit balance to customer, I am getting this error:
Fatal Error: Call to a member function setCustomer() on boolean in
$balance = Mage::getModel('enterprise_customerbalance/balance')
->setCustomer($customer)
->setWebsiteId($websiteId)
->setAmountDelta($anyNumber)
->setComment($data['comment']);
$balance->save();
3
Answers
Make sure this model class (or its parent) has a method named setCustomer()
Share model Code to get further advice. Normally class constructors don’t return boolean.
after some code review here you are:
It seems the code
Mage::getModel('enterprise_customerbalance/balance')
returnsfalse
.Please, verify if you have the
Enterprise_CustomerBalance_Model_Balance
class.Maybe you are trying to use the code of Magento Enterprise Edition for Magento Community Edition.
If you watch the value of
$className
in the methodgetModelInstance
of theMage_Core_Model_Config
class. It returns the ‘Mage_Enterprise_Customerbalance_Model_Balance’ value in Magento Community Edition. There is no such class and the functionMage::getModel('enterprise_customerbalance/balance')
returns false.You may try to check the edition with the code (it should work if the Magento Community version >= 1.7) –
Mage::getEdition()