3

My Magento version is 1.9.2.2. My config.xml is

<global>
        <models>
            <homeslider>
                <class>Transformer_HomeSlider_Model</class>
                <resourceModel>homeslider_resource</resourceModel>
            </homeslider>
            <homeslider_resource>
                <class>Transformer_HomeSlider_Model_Resource</class>
                <entities>
                    <slider>
                        <table>home_slider</table>
                    </slider>
                </entities>
            </homeslider_resource>
        </models>

<resources>
    <slider_setup>
        <setup>
            <module>Transformer_HomeSlider</module>
            <class>Transformer_HomeSlider_Model_Resource_Setup</class>
        </setup>
    </slider_setup>
</resources>
    ...
    </global>

My Model in Models/Slider.php is

class Transformer_HomeSlider_Model_Slider extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        $this->_init('homeslider/slider');
    }
}

and resource file Models/Resource/Slider.php is

class Transformer_HomeSlier_Model_Resource_Slider extends Mage_Core_Model_Resource_Db_Abstract
{
    public function _construct()
    {
        $this->_init('homeslider/slider','slider_id');
    }
}

My database setup script perfectly working when module run i.e table created in database. But When I want to save data on database it says

Fatal error: Call to a member function beginTransaction() on boolean in C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Abstract.php on line 313

I Call Model by

$slider_model = Mage::getModel('homeslider/slider');

My controller function is

public function saveAction()
    {
        $slider_model = Mage::getModel('homeslider/slider');
        if ($data = $this->getRequest()->getPost()) {
            try {
                $slider_model->setSliderNumber($data['slider_number']);
                $slider_model->setUrlLink($data['url_link']);
                $slider_model->save();
                Mage::getSingleton('adminhtml/session')
                    ->addSuccess($this->__("Your Slider has been saved"));
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')
                    ->addError($e->getMessage());
            }
        }
        $this->_redirect('*/*/edit');
    }

I var_dump($data) where I get form-data that is ok. Where is my problem? Thank you.

2
  • can you show the rest of the code where you save the slider? Aug 9, 2017 at 17:15
  • I update my post with controller save function. Aug 9, 2017 at 17:20

1 Answer 1

2

You have a typo in your resource class name:

Transformer_HomeSlier_Model_Resource_Slider should be Transformer_HomeSlider_Model_Resource_Slider

1
  • Thank you very much. Sorry for my Mistake. Everything is fine now. Aug 9, 2017 at 17:31

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.