blog

Debugging Shipping Issues in Magento

published in

Magento

comments

2

Sometimes something as simple as setting up a shipping method in Magento can cause you a headache. Earlier this week I wasn’t able to get the FedEx shipping method working – since all you need is the clients account number its not like this should be hard; but sometimes you run into problems. The best method to debug the shipping method issues is to enable the logs in Magento. Log in to the admin area and navigate to configuration > developer > log settings and then set enabled to yes.

FedEx

In the case of FedEx not working, find the file:

  • app/code/core/Mage/Usa/Model/Shipping/FedEx.php (prior to 1.4)
  • app/code/core/Mage/Usa/Model/Shipping/Carrier/FedEx.php (1.4)

Find this line of code in the _getXmlQuotes function:

// find this around line 414 in the _getXmlQuotes function

$responseBody = curl_exec($ch);

and right below this add this temporarily:

// add:

Mage::log($responseBody);

USPS

In the case of USPS not working, find the file:

  • app/code/core/Mage/Usa/Model/Shipping/Usps.php (prior to 1.4)
  • app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php (1.4)

Find this line of code in the _getXmlQuotes function:

// find this around line 239 in the _getXmlQuotes function

$responseBody = $response->getBody();

and right below this add this temporarily:

// add:

Mage::log($responseBody);

Checking the Error Logs

This will tell Magento to log the shipping issue. From here you can go to the front end of the site and lets say, go through the checkout process and get the shipping error, at which point the error logs have recorded the issue. Navigate in Magento’s folder structure to the log files:

  • var/log/system.log
  • var/log/exception.log

Once you open up system.log you should see some errors, similar to this:

// crappy error

<Error><Code>58659</Code><Message>Invalid weight for service type</Message></Error>

Quite simply shipping wasn’t working as the product I was testing with had a weight of 0. I should have looked at the product settings to begin with. Be sure to remove any code from these core files and disable Magento’s error logging when you have resolved your issue(s). This method can be applied to any of the Magento shipping methods (FedEx, UPS, USPS etc) as well as general debugging. Hope this helps someones with their issues.

This entry was posted in Magento and tagged , , . Bookmark the permalink.

2 Responses to Debugging Shipping Issues in Magento

  1. Tad says:

    Quite helpful. I noticed there are two places in the files with $responseBody = $response->getBody(); – does it matter which I use?

  2. admin says:

    Tad – only needed in the _getXmlQuotes function.

    Bret

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>