ฉันกำลังพยายามทำความเข้าใจกับการโทรและการใช้โมเดลในวีโอไอพี
งานปัจจุบันของฉันคือเพียงแสดงสตริงที่อยู่ในโมเดลโดยการเรียกมันจากคอนโทรลเลอร์
เมื่อพยายามโทร SimpleOutput.php ฉันได้รับข้อความแสดงข้อผิดพลาดแจ้งว่ามีการเรียกใช้วัตถุที่ไม่ใช่ ฉันได้ var_dumped มันอย่างที่คุณเห็นแล้วมันก็คืนค่าเท็จ
ฉันได้ดูโค้ดของฉันแล้ว และด้วยความเข้าใจที่จำกัดเกี่ยวกับสิ่งที่ฉันต้องทำใน 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/คอนโทรลเลอร์/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 is some text from the simple output model inside the basic text function';
}
}