0

How can I Override a Third Party Extension? The Path for the Extension is: app/code/extension_company/extension/model/file.php

Can I Override this php File by my custom Theme?

  • Please provide additional information about the exact circumstances and exactly what you are trying to accomplish. Without specifics, it's hard to solve your exact problem and ensure you're using the best approach. cf. meta.stackexchange.com/a/66378 – Ryan Hoerr May 8 '17 at 18:37
1

Yes,You can use plugin at here.

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="extension_company/extension/model/file">
        <plugin disabled="false" name="overrider_the_third_part_file" sortOrder="10" type="[VendorName]\[ModuleName]\Plugin\FILE"/>
    </type>
</config>

Use after,before,around method basic of your requirement.

  • Ok, and where must i save the custom di.xml file? – user3778868 May 8 '17 at 17:45
0

You can override the php file in your own custom module. You can create your module and override the php file like this:

app/code/Vendor/module_name/model/classname.php

You also need to create di.xml file at the following location wherein you will set the preference for your Class in classname.php

app/code/Vendor/module_name/etc/di.xml

di.xml example

<?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="Magento\ModuleName\Model\Classname" type="Vendor\ModuleName\Model\Classname" />
</config>

classname.php example

<?php
namespace Vendor\ModuleName\Model;

class Classname extends \Magento\ModuleName\Model\Classname
{
   //your code goes here.
}

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.