I want to override this core file


I have already followed the standard Magento2 approaches to override core file but unable to fetch tax properties that I want to modify.

closed as unclear what you're asking by Fabian Schmengler, Jai, Sukumar Gorai, Priyank, Manashvi Birla Oct 15 '18 at 5:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • what you want to do , are you trying with preference or using plugin ? – Naveed Asim Sep 18 '18 at 12:26
  • Under Quote there are 4 classes. Which one you want to override? – Sukumar Gorai Sep 18 '18 at 13:11
  • I have tried both approaches and never could achieve the result. – Lak-Solve-hay Sep 19 '18 at 9:23

Hey you can do it by making changes in di.xml file you need to do changes in your shipping module.You can also override core blocks and helper if you want go through this link it might help. Override Magento 2 files

  • I have tried it dude but no help, that was my first step. – Lak-Solve-hay Sep 19 '18 at 9:24

You have to override using preference. Please follow step to override the file.


<?xml version="1.0"?>
* Copyright 2016 aheadWorks. All rights reserved.
* See LICENSE.txt for license details.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Tax\Model\Sales\Total\Quote\Shipping" type="<vendor>\<modulename>\Model\Sales\Total\Quote\Shipping" />    



 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
namespace <vendor>\<modulename>\Model\Sales\Total\Quote;

 * Description of Shipping
 * @author dharmendra
class Shipping extends Magento\Tax\Model\Sales\Total\Quote\Shipping
    //put your code here

Try using above code you have to override all function of that class.

I am given example of Shipping class you have to override any class like this.

Still you have facing any issue let me know.


You can use di.xml file on your custom module for override anythings you want

Example override model : Magento\Checkout\CustomerData\AbstractItem

<?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="Magento\Checkout\CustomerData\AbstractItem">
        <plugin name="Company_Module::Minicart_Image_Changer" type="Company\Module\Plugin\Minicart\Image" sortOrder="1"/>

Code model :

namespace Company\Module\Plugin\Minicart;
class Image
    public function aroundGetItemData($subject, $proceed, $item)
        $additionalOptions = $item->getOptionByCode('additional_options');
        if (count($additionalOptions) > 0) {
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
            $additionalOptions = (array) $objectManager->get('Magento\Framework\Serialize\SerializerInterface')->unserialize($additionalOption->getValue());
            $result['product_image']['src'] = $pdcImage;
        $result['product_image']['src'] = '';
        return $result; 

For model vendor/magento/module-tax/Model/Sales/Total/Quote, code for di.xml file :

<?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\Tax\Model\Sales\Total\Quote" type="Company\Module\Model\Sales\Total\Quote" />

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