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
- 下一篇: 腾讯在线人数统计_PHP + REDIS