{ Hello Magento 2 }

解决 Magento 2 应用问题,更注重深度挖掘。(ง •̀_•́)ง

0%

Magento 1 创建简单模块

直接上代码吧。 必不可少的是 app/etc/modules/MyCompany_MyModule.xmlapp/code/local/MyCompany/MyModule/etc/config.xml File: app/etc/modules/ThankIT_Devtool.xml

1
2
3
4
5
6
7
8
9
<?xml version="1.0"?>
<config>
<modules>
<ThankIT_Devtool>
<active>true</active>
<codePool>local</codePool>
</ThankIT_Devtool>
</modules>
</config>

File:app/code/local/ThankIT/Devtool/etc/config.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0"?>
<config>
<modules>
<ThankIT_Devtool>
<version>0.1.0</version>
</ThankIT_Devtool>
</modules>
<frontend>
<routers>
<thankit_SomeFreeRouterName1>
<use>standard</use>
<args>
<module>ThankIT_Devtool</module>
<frontName>dev</frontName>
</args>
</thankit_SomeFreeRouterName1>
</routers>
</frontend>
</config>

File: app/code/local/ThankIT/Devtool/controllers/IndexController.php

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

class ThankIT_Devtool_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Hello developer...';
}
public function sayHelloAction()
{
echo 'Hello one more time...';
}
}

下面访问 http://yoursite.com/dev/index/sayhello 就会出现 Hello one more time... 了。