0

I am Created Custom Module "Recipe" (module name). when I add a mass action for status Magento throws an error like "Fatal Error: Call to a member function getOptionArray() on a non-object "

My Grid file code:

$statuses = Mage::getSingleton('recipe/status')->getOptionArray();

Also in my config.xml file code:

<resourceModel>recipe_mysql4</resourceModel>

So Can any one please tell me what was the mistake?

My Magento Version is: 1.9.2.3

7
  • have you created model file if yes then post code of status file Dec 19, 2016 at 7:26
  • I am created model file but did not know what was the code I need to add code of status in model file Dec 19, 2016 at 7:31
  • can you please tell me that? Dec 19, 2016 at 7:32
  • can you post the config.xml file?
    – Marius
    Dec 19, 2016 at 7:36
  • 1
    Make sure you have the class Sigmasolve_Recipe_Model_Status with the method provided by Prashant Valanda and the defined constants STATUS_ENABLED and STATUS_DISABLED
    – Marius
    Dec 19, 2016 at 7:57

1 Answer 1

1

You need to add all option for status like as below

Add file at Namespace/modulename/Model/Status.php

   /**
     * Retrieve option array
     *
     * @return array
     */
    static public function getOptionArray()
    {
        return array(
            self::STATUS_ENABLED    => Mage::helper('catalog')->__('Enabled'),
            self::STATUS_DISABLED   => Mage::helper('catalog')->__('Disabled')
        );
    }

Above is example of code

4
  • I put above code in collection.php file But magento gives same error Dec 19, 2016 at 7:40
  • Updated answer please check it and create file at given path Dec 19, 2016 at 8:57
  • Thanks Prashant : Resolved Error. But Now get "Please select Recipe(s)" this error , i am already select checkbox Dec 19, 2016 at 9:18
  • public function massStatusAction() { $recipeIds = $this->getRequest()->getParam('recipe'); //print_r ($recipeIds);exit; if(!is_array($recipeIds)) { Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Recipe(s)')); } Dec 19, 2016 at 9:20

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.