Magento model ends with Invalid method xxx :: beginTransaction (Array ()

I am trying to write data to a table in a database. I finally set up my model, but I cannot write data to it.

I keep getting this error:

Invalid method Turnkeye_Adminform_Model_Mysql4_Iaso::beginTransaction(Array ( ) ) Trace: #0 E:\projects\magento\app\code\core\Mage\Core\Model\Abstract.php(313): Varien_Object->__call('beginTransactio...', Array) #1 E:\projects\magento\app\code\core\Mage\Core\Model\Abstract.php(313): Turnkeye_Adminform_Model_Mysql4_Iaso->beginTransaction() #2 E:\projects\magento\app\code\community\Turnkeye\Adminform\controllers\Adminhtml\AdminformController.php(47): Mage_Core_Model_Abstract->save() #3 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(420): Turnkeye_Adminform_Adminhtml_AdminformController->saveAction() #4 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('save') #5 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #6 E:\projects\magento\app\code\core\Mage\Core\Model\App.php(347): Mage_Core_Controller_Varien_Front->dispatch() #7 E:\projects\magento\app\Mage.php(640): Mage_Core_Model_App->run(Array) #8 E:\projects\magento\index.php(80): Mage::run('', 'store') #9 {main} 

Due to the amount of code I sent it to pastebin:

controllers /Adminhtml/AdminformController.php

etc / config.xml

etc / adminhtml.xml

Model /iaso.php

Model / Mysql4 / Iaso.php

+4
source share
1 answer

This does not work because your code defines

 Turnkeye_Adminform_Model_Mysql4_Iaso extends Mage_Core_Model_Abstract 

which is wrong.

You need to extend the resource model that belongs to the class that extends the abstract class Mage_Core_Model_Resource_Abstract . This is where beginTransaction() defined.

This is usually done by extending from Mage_Core_Model_Mysql4_Abstract , because there are several methods that use the standard mySQL resources in Magento, and they are defined through:

 Mage_Core_Model_Mysql4_Abstract extends Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Resource_Abstract 

So, changing the definition to

 Turnkeye_Adminform_Model_Mysql4_Iaso extends Mage_Core_Model_Mysql4_Abstract 

should get you back on track.

+3
source

Source: https://habr.com/ru/post/1413145/


All Articles