私は、magento でモデルを呼び出して使用する方法を理解しようとしています。
私の現在のタスクは、コントローラーから呼び出して、モデルに保持されている文字列を単純に表示することです。
SimpleOutput.php を呼び出そうとすると、非オブジェクトが呼び出されたというエラー メッセージが表示されます。ご覧のとおり、var_dumped したところ、false が返されます。
私は自分のコードを調べましたが、Magento で何をする必要があるかについての理解が限られているため、すべてが正しいです。明らかに私は何かが欠けています。誰かが見て、それがタイプミスである場合はどこを見ればよいか、単純なスペルミス以上のものである場合は、何を見逃したのか、何をすべきだったのか、そしてその理由を説明してもらえますか?
私のコードは以下です
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/モデル/simpleoutput.php
class Ts_Firstmodule_Model_SimpleOutput extends Mage_Core_Model_Abstract
{
public function basicText()
{
echo 'this is some text from the simple output model inside the basic text function';
}
}