I do not know for what reason an error occurs when saving the model:

Fatal error: Call to a member function beginTransaction () on boolean

The model looks like this:

class Brain_CrownCaliber_Model_Processcrown extends Mage_Core_Model_Abstract { protected function _construct() { $this->_init('brain_crowncaliber/crown_caliber_process'); } public function addProductToCrown($idArray) { foreach ($idArray as $id) { $this->setData('product_id', $id); } Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $this->save(); } } 

I register it in config.xml :

 <models> <brain_crowncaliber> <class>Brain_CrownCaliber_Model</class> <resourceModel>brain_crowncaliber_resource</resourceModel> </brain_crowncaliber> </models> 

What could be the problem? I do not even understand what I can be wrong here.

Resource Section:

 <brain_crowncaliber_resource> <class>HexBrain_CrownCaliber_Model_Resource</class> <entities> <crown_caliber_process> <table>crown_caliber_process</table> </crown_caliber_process> </entities> </brain_crowncaliber_resource> 

Resource model

 class Brain_CrownCaliber_Model_Resource_Processcrown extends Mage_Core_Model_Resource_Db_Abstract { protected function _construct() { $this->_init('brain_crowncaliber/crown_caliber_process', 'process_id'); } } 
  • initialization of _construct() on php __construct() try to replace. - Naumov
  • @Naumov, did not produce results (Error did not change - Maybe_V
  • Section where resurcModel transfer this brain_crowncaliber_resource from the brain_crowncaliber_resource - Naumov
  • @Naumov, edited the question - Maybe_V
  • code resource_model where? - Naumov

1 answer 1

I will issue as an answer because the comment does not allow formatting normally

here is the method in the file app/code/core/Mage/Core/Model/Config.php line 1349

 /** * Get model class instance. * * Example: * $config->getModelInstance('catalog/product') * * Will instantiate Mage_Catalog_Model_Mysql4_Product * * @param string $modelClass * @param array|object $constructArguments * @return Mage_Core_Model_Abstract|false */ public function getModelInstance($modelClass='', $constructArguments=array()) { $className = $this->getModelClassName($modelClass); if (class_exists($className)) { Varien_Profiler::start('CORE::create_object_of::'.$className); $obj = new $className($constructArguments); Varien_Profiler::stop('CORE::create_object_of::'.$className); return $obj; } else { return false; } } 

make var_dump($className) to see what class has been formed, it is probably wrong. We go further to the getModelClassName() method in general we reach the method 1219 of the same file getGroupedClassName()

  /** * Retrieve class name by class group * * @param string $groupType currently supported model, block, helper * @param string $classId slash separated class identifier, ex. group/class * @param string $groupRootNode optional config path for group config * @return string */ public function getGroupedClassName($groupType, $classId, $groupRootNode=null) { if (empty($groupRootNode)) { $groupRootNode = 'global/'.$groupType.'s'; } $classArr = explode('/', trim($classId)); $group = $classArr[0]; $class = !empty($classArr[1]) ? $classArr[1] : null; if (isset($this->_classNameCache[$groupRootNode][$group][$class])) { return $this->_classNameCache[$groupRootNode][$group][$class]; } $config = $this->_xml->global->{$groupType.'s'}->{$group}; // First - check maybe the entity class was rewritten $className = null; if (isset($config->rewrite->$class)) { $className = (string)$config->rewrite->$class; } else { /** * Backwards compatibility for pre-MMDB extensions. * In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left * to keep name of previously used nodes, that still may be used by non-updated extensions. */ if ($config->deprecatedNode) { $deprecatedNode = $config->deprecatedNode; $configOld = $this->_xml->global->{$groupType.'s'}->$deprecatedNode; if (isset($configOld->rewrite->$class)) { $className = (string) $configOld->rewrite->$class; } } } // Second - if entity is not rewritten then use class prefix to form class name if (empty($className)) { if (!empty($config)) { $className = $config->getClassName(); } if (empty($className)) { $className = 'mage_'.$group.'_'.$groupType; } if (!empty($class)) { $className .= '_'.$class; } $className = uc_words($className); } $this->_classNameCache[$groupRootNode][$group][$class] = $className; return $className; } 

what this method does, takes from the config ime a prefix class which is specified in the models section in general after you see the generated ime class you understand where the error is. But from experience I will say where is the typo in the config. In principle, the edited version of the CO should work.

  • Very grateful for helping to figure it out! There was an error first in the config (a bit messed up with the model nodes). And in the model itself is not correct namespace indicated !! ) - Maybe_V