- You could create another module to override the current one
app/code/Vendor/Module/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="WebShopApps\MatrixRate\Model\Carrier\Matrixrate" type="Vendor\Module\Model\Carrier\Matrixrate" /> </config>
app/code/Vendor/Module/Model/Carrier/Matrixrate.php
<?php namespace Vendor\Module\Model\Carrier; use Magento\Quote\Model\Quote\Address\RateRequest; class Matrixrate extends \WebShopApps\MatrixRate\Model\Carrier\Matrixrate implements \Magento\Shipping\Model\Carrier\CarrierInterface { protected $helper; public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory, \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\MatrixrateFactory $matrixrateFactory, array $data = [] ) { parent::__construct($scopeConfig, $rateErrorFactory, $logger, $rateResultFactory, $resultMethodFactory, $matrixrateFactory, $data); } /** * @param \Magento\Quote\Model\Quote\Address\RateRequest $request * @return bool|\Magento\Shipping\Model\Rate\Result */ public function collectRates(RateRequest $request) { // Do some stuff here return parent::collectRates($request); } }
app/code/Vendor/MatrixRate/etc/module.xml
<?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="Vendor_MatrixRate" setup_version="1.0.0"> <sequence> <module name="WebShopApps_MatrixRate"/> </sequence> </module> </config>
app/code/Vendor/MatrixRate/composer.json
{ "name": "vendor/matrixrate", "description": "", "require": { "php": "~5.5.0|~5.6.0|~7.0.0", "webshopapps/module-matrixrate": "null", "magento/magento-composer-installer": "*" }, "suggest": { }, "type": "magento2-module", "version": "1.0.0", "license": [ ], "autoload": { "files": [ "registration.php" ], "psr-4": { "Vendor\\MatrixRate\\": "" } }, "extra": { "map": [ [ "*", "Vendor/MatrixRate" ] ] } }
app/code/Vendor/MatrixRate/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Vendor_MatrixRate', __DIR__ );
- You could use composer patcher to patch directly to vendor folder
Reference link