0

I am new to Magento. I try to create a simple module but it's not working. I use http://www.pierrefay.com/magento-model-database-tutorial-54 to create simple Model.

but i am found Error

Invalid method Mage_Core_Block_Template::methodblock(Array
(
))";i:1;s:3082:"#0 E:\xampp\htdocs\magento_theme\app\design\frontend\default\modern\template\test\test2.phtml(12): Varien_Object->__call('methodblock', Array)
#1 E:\xampp\htdocs\magento_theme\app\design\frontend\default\modern\template\test\test2.phtml(12): Mage_Core_Block_Template->methodblock()
#2 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(241): include('E:\\xampp\\htdocs...')
#3 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('frontend\\defaul...')
#4 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#5 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#6 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#7 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#8 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#9 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#10 E:\xampp\htdocs\magento_theme\app\design\frontend\base\default\template\page\2columns-left.phtml(48): Mage_Core_Block_Abstract->getChildHtml('content')
#11 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(241): include('E:\\xampp\\htdocs...')
#12 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('frontend\\base\\d...')
#13 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#14 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#15 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Model\Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#16 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput()
#17 E:\xampp\htdocs\magento_theme\app\code\local\Pfay\Test\controllers\IndexController.php(21): Mage_Core_Controller_Varien_Action->renderLayout()
#18 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Pfay_Test_IndexController->indexAction()
#19 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#20 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#21 E:\xampp\htdocs\magento_theme\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#22 E:\xampp\htdocs\magento_theme\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#23 E:\xampp\htdocs\magento_theme\index.php(87): Mage::run('', 'store')
#24 {main}";s:3:"url";s:20:"/magento_theme/test/";s:11:"script_name";s:24:"/magento_theme/index.php";s:4:"skin";s:7:"default";}

my config file

<config>
    <modules>
        <Pfay_Test>
            <version>1.0.0</version>
        </Pfay_Test>
    </modules>
    <frontend>
    <global>


<blocks> 
<models>
<test>
     <class>Pfay_Test_Model</class>
     <resourceModel>test_mysql4</resourceModel>
 </test>
<test_mysql4>
     <class>Pfay_Test_Model_Mysql4</class>
     <entities>
         <test>
           <table>pfay_test</table>
         </test>
      </entities>
</test_mysql4>
</models>    
              <Test>
              <class>Pfay_Test_Block</class>
         </Test>
      </blocks>


   </global>

        <routers>
            <routeurfrontend>
            <use>standard</use>
            <args>
                <module>Pfay_Test</module>
                <frontName>test</frontName>
            </args>
            </routeurfrontend>
        </routers>
         <layout>
            <updates>
                <Pfay_Test>
                    <file>Test.xml</file>
                </Pfay_Test>
            </updates>
        </layout>        
    </frontend>
 </config>
3
  • Is the code you are using exactly as above? If so then you are opening the models node in your config.xml within the blocks node for one. Blocks and models must be defined separately... Commented Aug 1, 2014 at 13:44
  • I am changing config.xml and create separately block and model <global> <models> <test> <class>Pfay_Test_Model</class> <resourceModel>test_mysql4</resourceModel> </test> <test_mysql4> <class>Pfay_Test_Model_Mysql4</class> <entities> <test> <table>pfay_test</table> </test> </entities> </test_mysql4> </models> <blocks> <Test> <class>Pfay_Test_Block</class> </Test> </blocks> </global>
    – coder
    Commented Aug 1, 2014 at 13:56
  • Sure ok, well maybe update your post with the actual code you are working with. Commented Aug 1, 2014 at 14:55

1 Answer 1

1

The method methodblock does not exist int the class that is rendering the template (in this case Mage_Core_Block_Template).
I assume you are calling somewhere in template\test\test2.phtml this:

$this->methodblock(...);
4
  • I am create My template file frontend/defult/theme/template/test/test2.html and I am call there <?php echo $this->methodblock(); ?> but when i comment then it's working.
    – coder
    Commented Aug 1, 2014 at 13:42
  • Can you given Solution what i do give a result for it
    – coder
    Commented Aug 1, 2014 at 13:44
  • That's the solution. Don't call that method. There is no method with that name in that class.
    – Marius
    Commented Aug 1, 2014 at 13:59
  • What i do for call my model method run in theme? any solution for it
    – coder
    Commented Aug 1, 2014 at 14:50

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.