- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Magento 2 new FedEx api not getting the right price
Hello,
I just upgraded to 2.4.7-p2 to get the new FedEx api working.
Connection works fine but I'm not getting the right prices for our account.
FedEx tells us that we have a wrong param in the request :
"rateRequestType": [ "LIST" ],
Should be
"rateRequestType": [ "PREFERRED" ],
I could not see this option in admin.
Should it not figure there?
I tried to change this directly in vendor/magento/module-fedex/Model/Carrier.php and it seems to do the job.
But I also tried to override the Model to avoid update issues without luck.
Any idea on how I could get this fixed please?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 new FedEx api not getting the right price
Hello @ShapesGS
To override the Magento\Fedex\Model\Carrier class in a custom module in Magento 2, follow these steps:
- Create the Module Directory Structure: app/code/Vendor/FedexOverride/
- Registration File: Create the registration.php file: app/code/Vendor/FedexOverride/registration.php
- Module Configuration: Create the module configuration file: app/code/Vendor/FedexOverride/etc/module.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Vendor_FedexOverride" setup_version="1.0.0"/> </config>
- Override Class: Create the overriding class: app/code/Vendor/FedexOverride/Model/Carrier.php
namespace Vendor\FedexOverride\Model; use Magento\Fedex\Model\Carrier as FedexCarrier; class Carrier extends FedexCarrier { // Override methods here public function collectRates(RateRequest $request) { // Your custom logic $result = parent::collectRates($request); // Modify the $result as needed return $result; } }
- Create Dependency Injection Configuration: Create the di.xml file to inform Magento to use your custom class instead of the original one: app/code/Vendor/FedexOverride/etc/di.xml
<type name="Magento\Fedex\Model\Carrier"> <plugin name="fedex_carrier_override" type="Vendor\FedexOverride\Model\Carrier" /> </type>
- Run the Following Commands: Enable the module and update the database schema:
php bin/magento module:enable Vendor_FedexOverride
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9