I am getting the error in my custom admin module -
Fatal error: Call to a member function setRecipeProducts() on a non-object in C:\xampp\htdocs\sample\app\code\local\Sigmasolve\Recipe\controllers\Adminhtml\RecipeController.php on line 155
Sigmasolve_Recipe
is my custom module name and here is the controller file:
public function _initRecipe()
{
$this->loadLayout()
->_title($this->__('Product Grid'))
->renderLayout();
}
public function productsAction()
{
$this->_initRecipe(); //if you don't have such a method then replace it with something that will get you the entity you are editing.
$this->loadLayout();
$this->getLayout()->getBlock('recipe.edit.tab.product')
->setRecipeProducts($this->getRequest()->getPost('recipe_products', null));
$this->renderLayout();
}
public function productsgridAction()
{
$this->_initRecipe();
$this->loadLayout();
$this->getLayout()->getBlock('recipe.edit.tab.product')
->setRecipeProducts($this->getRequest()->getPost('recipe_products', null));
$this->renderLayout();
}
<?xml version="1.0"?>
<config>
<modules>
<Sigmasolve_Recipe>
<version>1.0.0</version>
</Sigmasolve_Recipe>
</modules>
<!-- <frontend>
<routers>
<recipe>
<use>standard</use>
<args>
<module>Sigmasolve_Recipe</module>
<frontName>recipe</frontName>
</args>
</recipe>
</routers>
<layout>
<updates>
<recipe>
<file>recipe.xml</file>
</recipe>
</updates>
</layout>
</frontend> -->
<admin>
<routers>
<recipe>
<use>admin</use>
<args>
<module>Sigmasolve_Recipe</module>
<frontName>recipe</frontName>
</args>
</recipe>
</routers>
</admin>
<adminhtml>
<menu>
<recipe module="recipe">
<title>Recipe</title>
<sort_order>71</sort_order>
<children>
<items module="recipe">
<title>Manage Recipe</title>
<sort_order>0</sort_order>
<action>recipe/adminhtml_recipe</action>
</items>
</children>
</recipe>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<recipe>
<title>Recipe Module</title>
<sort_order>200</sort_order>
</recipe>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<recipe>
<file>recipe.xml</file>
</recipe>
</updates>
</layout>
</adminhtml>
<global>
<models>
<recipe>
<class>Sigmasolve_Recipe_Model</class>
<resourceModel>recipe_mysql4</resourceModel>
</recipe>
<recipe_mysql4>
<class>Sigmasolve_Recipe_Model_Mysql4</class>
<entities>
<recipe>
<table>recipe</table>
</recipe>
<recipe_product>
<table>recipe_product</table>
</recipe_product>
</entities>
</recipe_mysql4>
</models>
<resources>
<recipe_setup>
<setup>
<module>Sigmasolve_Recipe</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</recipe_setup>
<recipe_write>
<connection>
<use>core_write</use>
</connection>
</recipe_write>
<recipe_read>
<connection>
<use>core_read</use>
</connection>
</recipe_read>
</resources>
<blocks>
<recipe>
<class>Sigmasolve_Recipe_Block</class>
</recipe>
</blocks>
<helpers>
<recipe>
<class>Sigmasolve_Recipe_Helper</class>
</recipe>
</helpers>
</global>
</config>