magento php 所需模块,Magento 博客
Magento2已經(jīng)發(fā)布一段時(shí)間了。Magento1.9.x到Magento2,模塊的結(jié)構(gòu)已經(jīng)出現(xiàn)很大的變化。今天,我們將指導(dǎo)您如何創(chuàng)建一個(gè)簡(jiǎn)單的Magento2模塊。
創(chuàng)建模塊之前,我們對(duì)比一下Magento的兩個(gè)版本之間的目錄結(jié)構(gòu)的差異。
一Magento1.0和Magento2.0之間的差別,在Magento2有代碼的結(jié)構(gòu)的急劇變化。要了解如何創(chuàng)建Magento2一個(gè)模塊,我們列出的Magento2和magento1.x的差別:
開始創(chuàng)建一個(gè)簡(jiǎn)單的Magento2模塊
我們創(chuàng)建一個(gè)命名空間為Ves模塊名稱為HelloWorld的magento插件。
Step1: 我們需要?jiǎng)?chuàng)建一個(gè)module.xml文件在app/code/Ves/HelloWorld/etc目錄。
1
2
3
4
5
6
7
Step2: 創(chuàng)建app/code/Ves/HelloWorld/registration.php文件
1
2
3
4
5
6
7
8
9
resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
/**
* Blog Index, shows a list of recent blog posts.
*
* @return \Magento\Framework\View\Result\PageFactory
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Ves HelloWorld'));
return $resultPage;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
resultPageFactory=$resultPageFactory;
parent::__construct($context);
}
/**
* Blog Index, shows a list of recent blog posts.
*
* @return \Magento\Framework\View\Result\PageFactory
*/
publicfunctionexecute()
{
$resultPage=$this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Ves HelloWorld'));
return$resultPage;
}
}
Step5: Create a layout file in the following directory app\code\Ves\Helloworld\View\frontend\layout\helloworld_index_index.xml
1
2
3
4
5
6
7
8
9
10
Step6: Lets create a block for our module. Create block file app/code/Ves/HelloWorld/Block/HelloWorld.php
總結(jié)
以上是生活随笔為你收集整理的magento php 所需模块,Magento 博客的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 查找100 sql oracle,Ora
- 下一篇: linux 文件目录操作,Linux系统