I am trying to override UPS shipping Carrier. But it is not override.
etc/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="Magento\Ups\Model\Carrier" type="Sarvesh\Tiwari\Model\Carrier" /> </config> Sarvesh/Tiwari/Model/Carrier
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile namespace Sarvesh\Tiwari\Model; use Magento\Quote\Model\Quote\Address\RateResult\Error; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Simplexml\Element; use Magento\Ups\Helper\Config; use Magento\Framework\Xml\Security; /** * UPS shipping implementation * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Carrier extends \Magento\Ups\Model\Carrier { public function collectRates(RateRequest $request) { $this->setRequest($request); if (!$this->canCollectRates()) { return $this->getErrorMessage(); } $this->setRequest($request); $this->_result = $this->_getQuotes(); $this->_updateFreeMethodQuote($request); return $this->getResult(); } } but its not working anyone can help