Question

Recently magento-2.0.0-RC was launched and they added registration.php in every module root folder? So I just want to know is there any reason for that?

Can someone put light on this?

Was it helpful?

Solution

registration.php is kind of the entry point of your module. It's the equivalent of app/etc/modules/[Namespace]_[Module].xml from Magento 1.
But now, is part of the module itself.
it allows you to create modules in the app/code folder and in the vendor folder as well.
No matter where you add it, this file will be picked up by Magento and your module will be taken into consideration.

OTHER TIPS

i noticed two thing was changed from Magento ver. 1.0.0-beta (Oct) to Magento ver. 2.0.0-rc2
1. added new file in root folder of module called registration.php ex:-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 was changed previous we are mention method name in observer tag in event.xml now method was removed juts you need to mention only instance that is

<?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>

and in /ModuleName/Observer folder you need to create a file with function

public function execute()

that is

<?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;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top