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?
Hello @ShapesGS
To override the Magento\Fedex\Model\Carrier class in a custom module in Magento 2, follow these steps:
<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>
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; } }
<type name="Magento\Fedex\Model\Carrier"> <plugin name="fedex_carrier_override" type="Vendor\FedexOverride\Model\Carrier" /> </type>
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
You need to override the default FedEx carrier model without modifying core files. This ensures that your changes remain intact during future updates. The solution involves creating a custom module. First, set up a new module named Vendor_FedexOverride by defining it in app/code/Vendor/FedexOverride/registration.php and app/code/Vendor/FedexOverride/etc/module.xml.
Then, override the FedEx carrier model by creating a new class in app/code/Vendor/FedexOverride/Model/Carrier/Fedex.php, where you modify the _formulateRequest function to set "rateRequestType" to ["PREFERRED"]. Next, update Magento’s dependency injection by adding a preference in app/code/Vendor/FedexOverride/etc/di.xml, ensuring that Magento uses your custom class instead of the default one.
Finally, enable and deploy the module by running php bin/magento module:enable Vendor_FedexOverride, followed by php bin/magento setup:upgrade and php bin/magento cache:clean. This method correctly sets the required FedEx parameter while maintaining compatibility with future Magento updates.
Hello, the issue has been fixed in latest versions so I was able to delete the override but indeed it fixed the problem.
Best regards