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

  • have you created model file if yes then post code of status file – Prashant Valanda Dec 19 '16 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 – H_Parekh Dec 19 '16 at 7:31
  • can you please tell me that? – H_Parekh Dec 19 '16 at 7:32
  • can you post the config.xml file? – Marius Dec 19 '16 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 '16 at 7:57
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

| improve this answer | |
  • I put above code in collection.php file But magento gives same error – H_Parekh Dec 19 '16 at 7:40
  • Updated answer please check it and create file at given path – Prashant Valanda Dec 19 '16 at 8:57
  • Thanks Prashant : Resolved Error. But Now get "Please select Recipe(s)" this error , i am already select checkbox – H_Parekh Dec 19 '16 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)')); } – H_Parekh Dec 19 '16 at 9:20

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.