3

In magento 1 we have local - community - core areas inside app->code folder. When you want to override a functionality placing code with same names in local or community will do the job.

working in magento 2, I saw only one folder inside the app->code and it is magento. If we want to create an adjustment in price (eg: calculator.php ) do we have to re-write core files or we have to work in another way?.

If I create a module in app->code->magento->vendorname to rewrite pricecalculation in catalog, which structure do I have to create in order to change the value and give magento 2 the parameter to let the application know that I want to override the catalog price?.

3

In Magento2 You can overwrite using preference. Example:

in di.xml

<xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="core/class" type="your/local/class" />
</config>

But you should avoid this overwrite using preference because of rewrite conflict.

In Magento1 have rewrite conflict issue, So Magento2 overcome this issue using plugin Click here for more information about plugin

Try plugin than rewrite any class.

2

As you may know class rewrite its potential conflict changes and not recommended at all if you can avoid it.

Preferable solution is use plugins instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.