magento - Mage::getModel is returning false -
i trying grips calling , using models in magento.
my current task display string held in model calling controller.
when trying call simpleoutput.php error message saying non object has been called. have var_dumped see , return false.
i have looked @ code , limited understanding of need in magento have correct. i'm missing something. please take , if it's typo tell , if it's more simple spelling mistake explain ive missed , should have done , why?
my code below
ts/firstmodule/etc/config.xml
<?xml version="1.0" encoding="utf-8"?> <config> <modules> <ts_firstmodule> <version>0.1.0</version> </ts_firstmodule> </modules> <models> <firstmodule> <class>ts_firstmodule_model</class> </firstmodule> </models> <frontend> <routers> <firstmodule> <use>standard</use> <args> <module>ts_firstmodule</module> <frontname>firstmodule</frontname> </args> </firstmodule> </routers> </frontend> </config>
ts/firstmodule/controllers/indexcontroller.php
class ts_firstmodule_indexcontroller extends mage_core_controller_front_action { public function indexaction() { $simple = mage::getmodel('ts_firstmodule/simpleoutput'); var_dump($simple); } }
ts/firstmodule/model/simpleoutput.php
class ts_firstmodule_model_simpleoutput extends mage_core_model_abstract { public function basictext() { echo 'this text simple output model inside basic text function'; } }
you must wrap <models>
in <global>
, :
<global> <models> <firstmodule> <class>ts_firstmodule_model</class> </firstmodule> </models> </global>
don't hesitate take @ source of simpler core modules (eg, googleanalytics
), see how they're done , understand logic behind it.
Comments
Post a Comment