magento php 所需模块,Magento 博客
Magento2已經發布一段時間了。Magento1.9.x到Magento2,模塊的結構已經出現很大的變化。今天,我們將指導您如何創建一個簡單的Magento2模塊。
創建模塊之前,我們對比一下Magento的兩個版本之間的目錄結構的差異。
一Magento1.0和Magento2.0之間的差別,在Magento2有代碼的結構的急劇變化。要了解如何創建Magento2一個模塊,我們列出的Magento2和magento1.x的差別:
開始創建一個簡單的Magento2模塊
我們創建一個命名空間為Ves模塊名稱為HelloWorld的magento插件。
Step1: 我們需要創建一個module.xml文件在app/code/Ves/HelloWorld/etc目錄。
1
2
3
4
5
6
7
Step2: 創建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
總結
以上是生活随笔為你收集整理的magento php 所需模块,Magento 博客的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 查找100 sql oracle,Ora
- 下一篇: linux 文件目录操作,Linux系统