0

I am getting this error on save method of a model.

Fatal error: Call to a member function beginTransaction() on a non-object in /home/public_html/app/code/core/Mage/Core/Model/Abstract.php on line 313

$warranty = Mage::getModel('warrany/warrantydata');
$warranty->setOrderId($order_id);
$warranty->setSignifydScore($signifyd_score);
$warranty->setSignifydData(utf8_encode(serialize($data)));
$warranty->save();

I have this added xml for model

    <models>
    <warranty>
      <class>Website_Warranty_Model</class>
      <resourceModel>warranty_mysql4</resourceModel>
        </warranty>
       <warranty_mysql4>
              <class>Website_Warranty_Model_Mysql4</class>
          <entities>
            <warrantydata>
               <table>warrantydata</table>
        </warrantydata>
          </entities>
          </warranty_mysql4>
   </models>

i also have the collection and model file

class Website_Warranty_Model_Warrantydata extends Mage_Core_Model_Abstract{}

class Website_Warranty_Model_Mysql4_Warrantydata extends Mage_Core_Model_Mysql4_Abstract {}
2
  • Could you please add some more information? - What does your config.xml look like? - Did you create the class in the Model folder? Commented Sep 6, 2013 at 10:55
  • It seams obvious...$this->_getRsource() does not return an object
    – Marius
    Commented Sep 6, 2013 at 10:57

1 Answer 1

2

In your resource model Website_Warranty_Model_Mysql4_Warrantydata you need to add this method :

public function _construct(){
    $this->_init('warranty/warrantydata', 'entity_id'); //the second parameter must be the primary key in your warrantydata table. If it's not `entity_id` then change it
}

and in your model class Website_Warranty_Model_Warrantydata you need this method:

public function _construct(){
    parent::_construct();
    $this->_init('warranty/warrantydata');
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.