Magento 1 Class Rewrite in Magento 2 Using Dependency Injection

magento2overrides

Poking around Magento 2's core code, it looks like the old class rewrite system has been ripped out and replaced with a new dependency injection system.

Unfortunately, there's no documentation for this new system.

Does anyone have a module configuration sample that would let a user, in Magento 2, "rewrite" the class Mage_Catalog_Model_Product with a new class Packagename_Modulename_Model_Product, using the new dependency injection system?

Best Answer

Di configuration was moved to di.xml files, and format was modified. Now preferences look like this (di.xml):

<config>
    <preference for="{Interface_Or_Class_Name}" type="{Preferred_Class_Name}" />
</config>