1

When I change the status of brands in the leftpanel extension I get this error and it doesnt change the status Line 180 is this code ->load($leftpanelId)

Fatal error: Call to a member function load() on a non-object in /home/thebeau9/public_html/app/code/local/Nextgeni/Leftpanel/controllers/Adminhtml/BrandsController.php on line 180

public function massStatusAction()
{
    $leftpanelIds = $this->getRequest()->getParam('leftpanel');
    if(!is_array($leftpanelIds)) {
        Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
    } else {
        try {
            foreach ($leftpanelIds as $leftpanelId) {
                $leftpanel = Mage::getSingleton('leftpanel/leftpanel')
                    ->load($leftpanelId)
                    ->setStatus($this->getRequest()->getParam('status'))
                    ->setIsMassupdate(true)
                    ->save();
            }
            $this->_getSession()->addSuccess(
                $this->__('Total of %d record(s) were successfully updated', count($leftpanelIds))
            );
        } catch (Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        }
    }
    $this->_redirect('*/*/index');
}

Config.xml

<global>
    <models>
        <leftpanel>
            <class>Nextgeni_Leftpanel_Model</class>
            <resourceModel>leftpanel_mysql4</resourceModel>
        </leftpanel>
        <leftpanel_mysql4>
            <class>Nextgeni_Leftpanel_Model_Mysql4</class>
            <entities>
                <brand>
                    <table>leftpanel_brand</table>
                </brand>
                <treatment>
                    <table>leftpanel_treatment</table>
                </treatment>
                <ingredient>
                    <table>leftpanel_ingredient</table>
                </ingredient>
            </entities>
        </leftpanel_mysql4>
        <!-- Paypal config model override - Gk on 03-08-2015 -->
        <paypal>
            <rewrite>
                <!-- Model -->
                <config>Nextgeni_Leftpanel_Model_Config</config>
            </rewrite>
        </paypal>
        <!-- Paypal config model override - Gk on 19-08-2015 -->
        <paypal>

leftpanel.php in model

 class Nextgeni_Leftpanel_Block_Leftpanel extends Mage_Core_Block_Template

 {

 public function _prepareLayout()
{
    return parent::_prepareLayout();
}

 public function getLeftpanel()     
 { 
    if (!$this->hasData('leftpanel')) {
        $this->setData('leftpanel', Mage::registry('leftpanel'));
    }
    return $this->getData('leftpanel');

}

}

Brand.php in model

<?php

class Nextgeni_Leftpanel_Model_Brand extends Mage_Core_Model_Abstract

{

public function _construct()
     {
             parent::_construct();
             $this->_init('leftpanel/brand');
     }
 }
  • could you please post the content of your app/code/local/Nextgeni/Leftpanel/etc/config.xml ? – Raphael at Digital Pianism Oct 24 '16 at 10:23
  • 1
    @Raphael config.xml is added. – paranoid kid Oct 24 '16 at 10:30
  • Great and what is the content of app/code/local/Nextgeni/Leftpanel/Model/Leftpanel.php ? – Raphael at Digital Pianism Oct 24 '16 at 10:33
  • Which table you have tried to update? – Sohel Rana Oct 24 '16 at 10:34
  • @RaphaelatDigitalPianism added the leftpanel.php file. – paranoid kid Oct 24 '16 at 10:35
0

Whenever you get such error :

Fatal error: Call to a member function load() on a non-object

After calling Mage::getModel('foo/bar') that means that the class corresponding to foo/bar does not exist.

What to check

Checks that foo is declared in your module config.xml in the model node:

<global>
    <models>
        <foo>
            <class>Vendor_Module_Model</class>
        </foo>
    </model>
</global>

Checks that bar is an existing model under your Model folder: app/code/<codePool>/Vendor/Module/Model/Bar.php

In your case

Magento is looking for app/code/local/Nextgeni/Leftpanel/Model/Leftpanel.php but according to your comment, you don't have such file.

I'm not sure what your code is doing and you posted the content of a app/code/local/Nextgeni/Leftpanel/Model/Brand.php so I will assume that's the model that needed to be used in your controller.

Thus you can fix your problem by replacing:

$leftpanel = Mage::getSingleton('leftpanel/leftpanel')

With:

$leftpanel = Mage::getSingleton('leftpanel/brand')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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