magento-2.0.0-RC에 Registration.php를 추가한 이유는 무엇입니까?
-
13-12-2019 - |
문제
최근에 magento-2.0.0-RC
출시되었고 추가되었습니다 registration.php
모든 모듈 루트 폴더에 있습니까?그래서 나는 거기에 어떤 이유가 있는지 알고 싶습니다.
누군가 이것에 대해 밝힐 수 있습니까?
해결책
registration.php
는 모듈의 진입 점입니다.Magento 1의 app/etc/modules/[Namespace]_[Module].xml
와 동일합니다.
그러나 지금은 모듈 자체의 일부입니다.
app/code
폴더와 vendor
폴더에서도 모듈을 만들 수 있습니다.
추가 위치에 관계 없이이 파일은 Magento에 의해 집어 들고 모듈이 고려 될 것입니다.
다른 팁
Magento Ver에서 두 가지가 변경되었다는 것을 알아 차렸다.1.0.0- 베타 (OCT)에서 마젠토 버전.2.0.0-RC2
1. registration.php라는 모듈의 루트 폴더에 새 파일을 추가했습니다.
예 : -App \ Code \ SugarCode \ test \ registration.php
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Sugarcode_Test',
__DIR__
);
.
2.event.xml이 변경되었습니다 이전 우리는 event.xml의 옵저버 태그의 메소드 이름을 언급하고 있습니다. 이제 메소드는 juts를 제거했습니다
인스턴스 만 언급해야합니다<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">
<event name="sales_order_grid_collection_load_before">
<observer name="sales_order_grid_test" instance="Sugarcode\Test\Observer\Addtest" />
</event>
</config>
.
및 / moduleName / observer 폴더 함수가있는 파일을 만들어야합니다
public function execute()
.
입니다
<?php
namespace Sugarcode\Test\Observer;
class Addtest
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$obj=$observer->getEvent()->getOrderGridCollection();
$obj->getSelect()->joinLeft(
['testt' => 'testtable'],
"(main_table.entity_id = testt.id)",
[
'testt.title as title'
]
);
//$this->printlogquery(true);
//return $obj;
}
}
. 제휴하지 않습니다 magento.stackexchange