I am Using a third party Module and going to customize a model file in it.
I have tried by overriding the model class but it is not showing any effect.
What i am doing is, just taking one method that is.
private function getPrice() {
return 123455;
}
File that i want to override placed at in thirdparty Module:
ThirdPartyCompany\ThirdPartyModuleName\Model\Carrrier.php
The Structure of my module is as follows:
Model file placed at: MyCompany\MyModule\Model\Carrier.php
And it has the following code in it:
namespace MyCompany\MyModule\Model;
class Carrier extends \ThirdPartyCompany\ThirdPartyModuleName\Model\Carrier
{
private function getPrice() {
return 10000;
}
}
My di.xml file has the following code in it:
<?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="ThirdPartyCompany\ThirdPartyModuleName\Model\Carrier" type="MyCompany\MyModule\Model\Carrier"/>
</config>
And i have module.xml with the following code in it:
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MyCompany_MyModule">
<sequence>
<module name="Magento_Quote"/>
<module name="ThirdPartyCompany_ThirdPartyModuleName"/>
</sequence>
</module>
</config>
When i directly change getPrice() function in thirdparty module file and change the return value it is changed on frontend but after overriding in my custom module it making no effect.
What wrong i have doing is there any issue with my code or file structure?