Magento: How to Log UPS Rate Requests
If you have ever needed to debug UPS shipping prices then this may come in handy. I will show you how to log the xml request you send to UPS to generate rate quotes, and also log the response from ups.
- Enable Logging in the admin
- Copy /app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php to /app/code/local/Mage/Usa/Model/Shipping/Carrier/Ups.php
- Now make the following edits to the file you just created.
Edit the following code in _getCgiQuotes method
//Comment out original code
//return $this->_parseCgiResponse($responseBody);
//Log Request
$result = $this->_parseCgiResponse($responseBody);
foreach($result ->getRatesByCarrier($this->_code) as $upsRate){
if($upsRate instanceof Mage_Shipping_Model_Rate_Result_Error){
$timeCode = time();
Mage::log($params, null, 'ups-request-'.$timeCode.'.log');
Mage::log($response, null, 'ups-response-'.$timeCode.'.log');
Mage::log($responseBody, null, 'ups-response-body-'.$timeCode.'.log');
}
}
return $result ;
//END Changes

4 Responses to “ Magento: How to Log UPS Rate Requests ”
September 16th, 2011 at 2:44 am
I m using magento 1.4.1.1 and I dont see mage into the /app/code/local folder ……..Plz reply..
September 16th, 2011 at 7:10 am
You have to create it.
Magento loads files in a particular order, and because of this you can override files(does not work for all files, but does for most).
First /app/code/core files are loaded.
Then /app/code/community
Then /app/code/local
So by moving a file from /app/code/core/Mage/…
to /app/code/local/Mage/…
Magento will use the file in the local folder and not in the core folder.
September 19th, 2011 at 12:46 am
Thanks mike for reply but my site is not charging according to ups charges ……give any idea……..again thanks for reply
September 19th, 2011 at 6:15 am
Here are some pointers:
1. there are two methods for ups. normal rates and negotiated rates. Make sure you are setting up the proper method. Negotiated rates need a user account.
2. UPS will charge Dimensional weight on items that get shipped via Air. Magento does not handle dimensional rates. You would need to get a plugin to get correct rates if dimensional rates are being charged.
3. Talk to USP and ask there support to help you.
This blog was about how to log the requests so that you can talk to support and have data to talk about.