SlideShare a Scribd company logo
Best Practices for Magento Debugging
OVERVIEW
•    Environment configuration
•    Common Magento development problems and how to approach them
•    Using the right tools for the job: PHP debugging and profiling with Magento/
     Eclipse


I won’t be covering everything in minute detail. At the end of the presentation, I’ll
provide a link to slideshow and link to blog posts explaining different sections in more
detail.
Best Practices for Magento Debugging
AUTO-SET DEVELOPER MODE
•    Enable Mage::isDeveloperMode() on development and staging environments
      •  Preferably, set the MAGE_IS_DEVELOPER_MODE via .htaccess file or server
         configuration. Example:




      •  Alternatively, set the developer mode using conditional code in index.php.
         Example:
SHOW ALL ERRORS IN DEVELOPER MODE
•    Ensure that all errors are displayed when in developer mode:
WHY DETAILED ERROR AND EXCEPTION BACKTRACES ROCK

•    You can see all arguments passed to functions in the call stack
•    You can see all local variables at the location of the error/exception
•    You can customize xdebug to create links that allow you to jump to a specific line/
     file in your favorite editor


HOW DO I GET SUCH DETAIL?
•    Install Xdebug (an Apache module) on your development/staging servers
•    My recommended xdebug configuration values: http://bit.ly/gspkIK
Before
After
                                     Links to the
                                   location the file




                  Fully expanded
                    argument
                     variables




Local variables
HACK MAGENTO (SAFELY) TO ENABLE
BACKTRACES
•    Modify the Mage::run() method to not catch exceptions if developer mode is on
     (blog post explaining how to make this modification: http://bit.ly/feJE2y)
USING MAGE::LOG TO LOG DEBUG DATA
•     Mage::log() allows you to log code to either the default var/logs/system.log file, or
      a custom file.
       •  Mage::log(‘This is a custom message’, Zend_Log::INFO, ‘customfile.log’, true)
•     Pass Varien_Debug::backtrace(true, false) to Mage::log() to log a backtrace. This
      is helpful if you want to know what code is calling a specific section of code. This
      can be helpful when testing methods that are difficult to use a debugger on, such
      as Paypal code.
•     Log the attributes of a model using Mage::log($model->debug()) The debug()
      method prevents Mage::log from logging the dump of all of the nested objects
•      You can monitor the contents of the log files using:
     •  Command-line: tail –f <file_name>
     •  Mac: Console.app (Must have developer tools installed)
     •  Windows: Baretail (http://www.baremetalsoft.com/baretail/ )
CONFIGURE EXCEPTION HANDLER TO EMAIL
REPORTS
•    When a user of a live site encounters an error, Magento shows them a form
     (NOTE: on what conditions will Magento show a form vs a generic exception page)
     allowing them to submit the details that happened that caused that error. That
     exception will also be logged to var/log/exceptions.log
•    If you want to be notified about all exceptions via email, copy errors/
     local.xml.template to errors/local.xml and configure it to send reports via email
     and enter your email.
Best Practices for Magento Debugging
GET TO THE BOTTOM OF THE SQLSTATE ERRORS

•    What do you do when Magento throws a generic SQLSTATE database error?
•    An “Integrity contraint violation”, or some other SQLSTATE error, doesn’t tell you
     much, unless you can view the error and the backtrace
•    Especially relevant for errors encountered in the admin panel
•    We have to hack two files (these hacks are harmless)…
GET TO THE BOTTOM OF THE SQLSTATE ERRORS
Modify Zend_Db_Adapter_Pdo_Abstract to get backtraces for single queries
GET TO THE BOTTOM OF THE SQLSTATE ERRORS
Modify Zend_Db_Statement_Pdo to get backtraces for transactional query errors
THINGS TO CHECK WHEN A CUSTOM MODULE DOESN’T LOAD

Problem: You’ve created a basic skeleton of a module with a module xml file,
config.xml file, layout file, and block, but the module isn’t showing. Here are some
quick steps you can take to debug the issue:


1.  Ensure that the module’s xml file in app/etc/modules/ is being loaded. Tip: Add
    an error to the module’s config file and then reload the page. If the page throws
    an error, the file is being loaded.
2.  Ensure that the module’s config.xml file is being loaded using same technique
    above
3.  Ensure that the layout file is getting loaded using same technique above
4.  Ensure that caching is disabled and remove the cache directory (var/cache)
    manually if it isn’t
5.  If you’re not working on a case-sensitive partition, ensure the cases of your class
     names and xml references are correct.
DEBUGGING BY PROCESS OF ELIMINATION
Problem: You are working on a site with 5 third-party modules and 4 custom
modules. You’ve heavily modified the way that products work in the system. You run
into an error where products aren’t saving from the admin.
•    You can either:
      •  Start digging into the code to determine the cause of the issue, OR:
      •  Isolate the cause of the issue by progressively disabling the modules on the
         site until you identify which module is causing the error. Most of the time, this
         is the better approach.
•    After you identify the violating module, start commenting out different sections of
     the config.xml file until the issue goes away.
•    After you identify the bad class/file, go through the code, progressively
     eliminating different sections until you narrow it down to a line of code
ESOTERIC ERROR MESSAGE
Problem: Your client tries to place an order in the admin. When doing so, they get a
    generic error message about the product stock quantity not being able to be
    saved (NOTE: replace with real example, preferably one that can be recreated
    easily). You check the error and exception logs, but you have nothing to work
    with. What do you do?
•    Take the error message and search the Magento codebase for the error.
•    Once you locate the error, set a breakpoint and debug the error from there.
DISABLING A MODULE VS DISABLING BLOCK OUTPUT

•    Disabling block output explained
      •  You can access this option in System > Configuration > Advanced
      •  Disabling a module’s block output makes the XXXX class not output the
         contents of any blocks in that module
      •  Why would you disable a modules block output as opposed to disabling it?
           •  NOTE: Fill in details
      •  Core Magento classes that are commonly disabled
           •  Mage_Poll, Mage_Review, Mage_Tag, Mage_Wishlist (NOTE: Need to verify that
              there are no issues disabling these module‘s block output)
•    Disabling a module
      •  Change the <active>true</active> to false
      •  Remove the module’s config file from app/etc/modules
Best Practices for Magento Debugging
QUICK TIPS: DEBUGGING SHIPPING METHOD RATES

•    Problem: Your shipping rates are configured like they should be, but when you
     add certain items to your cart, the shipping section is showing an error message
     like “No shipping rates found”. Magento provides no easy way to see what errors
     the carriers are returning, and so these errors can be hard to debug.
•    Modify the classes in app/code/core/Mage/Usa/Model/Shipping/Carrier/
     <carrier_name>.php to log XML returned from carrier
      •  UPS: Filename, line number
      •  Fedex: Filename, line number
      •  USPS: Filename, line number
•    Once you have the full XML response data from the carrier, you can determine the
     cause of the error.
•    Common causes:
      •  The products in the cart have 0 weight
      •  NOTE: Add additional items…
DON’T BE AFRAID TO HACK - TEMPORARILY
•    Find the source of the problem
•    Set a debug point, or add a Mage::log() function to log the important data
Best Practices for Magento Debugging
OVERVIEW OF ECLIPSE DEBUGGING
•    Breakpoints / conditional breakpoints
      •  Stepping through code
•    Inspecting variables in local scope (especially relevant are the _data and _items
     arrays on models and collections)
•    Jumping back through the Call Stack to view variables in scope at that point in the
     stack
•    Watch expressions
•    Tip: Run code in current context using “Inspect”
BREAKPOINTS
•    Purposes
      •  Identify that Magento is hitting a certain section of code (can also use
         Mage::log(__METHOD__ . ‘ ‘ . __LINE); for that)
      •  Determine what a certain section of code does
•    Conditional breakpoints


SWITCH TO ECLIPSE FOR WALKTHROUGH
INSPECTING VARIABLES
•    Inspecting variables in local scope
       •  Many classes in Magento have recursive properties, so if you expand all
          properties, you’ll get an infinite nesting
       •  The _data array stores all of the data present in a model
       •  The _items array contains all of the items loaded in a collection


SWITCH TO ECLIPSE FOR WALKTHROUGH
CALL STACK
•    Shows all code that has been run up to that point
•    Clicking to previous lines in the call stack changes the variables in the local scope




SWITCH TO ECLIPSE FOR WALKTHROUGH
WATCH EXPRESSIONS
•    See what a certain expression would return if it was being run in the code at that
     point. Example: $product->getStatus();
•    Run code in current context using “Inspect”
      •  Use Ctl+Shift+I to run code in local scope


SWITCH TO ECLIPSE FOR WALKTHROUGH
QUESTIONS?
ZEND STUDIO-ONLY FEATURES
•    Comparison between PDT and Zend Studio
•    For debugging, the biggest advantages of Zend Studio are:
      •  Profiling
      •  Tight Zend Server integration (helpful if Magento site is running on Zend
         Server in production)


SWITCH TO Zend Studio FOR WALKTHROUGH

More Related Content

PPTX
Fixing Magento Core for Better Performance - Ivan Chepurnyi
PPTX
Magento Indexes
PPTX
Using of TDD practices for Magento
PPTX
Optimizing Magento by Preloading Data
PPTX
Meet Magento Belarus debug Pavel Novitsky (eng)
PPTX
WordPress plugin #2
PPTX
Testing C# and ASP.net using Ruby
PDF
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Magento Indexes
Using of TDD practices for Magento
Optimizing Magento by Preloading Data
Meet Magento Belarus debug Pavel Novitsky (eng)
WordPress plugin #2
Testing C# and ASP.net using Ruby
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance

What's hot (20)

PPTX
Growing up with Magento
PDF
Magento Attributes - Fresh View
PDF
Apex 5 plugins for everyone version 2018
PPTX
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
PPT
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
PPTX
AngularJs-training
PDF
Django design-patterns
PDF
JSLab. Алексей Волков. "React на практике"
PDF
Building Web Interface On Rails
PDF
Get AngularJS Started!
PDF
Advanced React Component Patterns - ReactNext 2018
PDF
Template rendering in rails
PDF
Curso Symfony - Clase 2
PDF
Manipulating Magento - Meet Magento Netherlands 2018
PDF
Beginner’s tutorial (part 2) how to integrate redux-saga in react native app
PDF
Practical Protocol-Oriented-Programming
PDF
Optimization in django orm
PDF
Alfredo-PUMEX
PPT
Test driven development_for_php
PDF
td_mxc_rubyrails_shin
Growing up with Magento
Magento Attributes - Fresh View
Apex 5 plugins for everyone version 2018
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
AngularJs-training
Django design-patterns
JSLab. Алексей Волков. "React на практике"
Building Web Interface On Rails
Get AngularJS Started!
Advanced React Component Patterns - ReactNext 2018
Template rendering in rails
Curso Symfony - Clase 2
Manipulating Magento - Meet Magento Netherlands 2018
Beginner’s tutorial (part 2) how to integrate redux-saga in react native app
Practical Protocol-Oriented-Programming
Optimization in django orm
Alfredo-PUMEX
Test driven development_for_php
td_mxc_rubyrails_shin
Ad

Similar to Best Practices for Magento Debugging (20)

PPTX
Magento Imagine 2011 - Magento Debugging - Erik Hansen, Classy Llama Studios
PPTX
Virtues of platform development
PDF
Federico Soich - Upgrading Magento Version
PPTX
Finding Your Way: Understanding Magento Code
PDF
Magento best practices
PPTX
Zendcon zray
PDF
Magento 2 Backend Development Essentials
PDF
Zepplin_Pronko_Magento_Festival Hall 1_Final
PDF
A Successful Magento Project From Design to Deployment
PPTX
php[world] Magento101
PPT
Introduction to Mangento
PPT
Mangento
PDF
Debugging and Magento
PPTX
Zendcon magento101
PPTX
PHP Dublin Meetup - Clean Code in PHP
PPTX
Magento Technical guidelines
PDF
Magento community edition user guide
PPTX
Igor Miniailo - Magento 2 API Design Best Practices
PDF
Giuliana Benedetti - Can Magento handle 1M products?
PPTX
Expert guidance on migrating from magento 1 to magento 2
Magento Imagine 2011 - Magento Debugging - Erik Hansen, Classy Llama Studios
Virtues of platform development
Federico Soich - Upgrading Magento Version
Finding Your Way: Understanding Magento Code
Magento best practices
Zendcon zray
Magento 2 Backend Development Essentials
Zepplin_Pronko_Magento_Festival Hall 1_Final
A Successful Magento Project From Design to Deployment
php[world] Magento101
Introduction to Mangento
Mangento
Debugging and Magento
Zendcon magento101
PHP Dublin Meetup - Clean Code in PHP
Magento Technical guidelines
Magento community edition user guide
Igor Miniailo - Magento 2 API Design Best Practices
Giuliana Benedetti - Can Magento handle 1M products?
Expert guidance on migrating from magento 1 to magento 2
Ad

More from varien (20)

PDF
Driving Business Innovation with Magento
PDF
Best Practices for Launching an Enterprise Business on Magento
ZIP
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
PPTX
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
PDF
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
PDF
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
PPTX
Magento's Imagine eCommerce Conference: Do You Queue?
PPTX
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
PPSX
Magento performancenbs
PDF
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
PPTX
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
PDF
Getting from Here to There: How to assess your business, define an overall eC...
ZIP
Magento Imagine eCommerce, Day 2, Yoav Kutner CTO
PDF
Optimizing Magento Performance with Zend Server
PPT
Magento Roy Rubin Amsterdam Presentation
PPT
Maximizing Magento: Getting the Most out of Multi-Store Management
PPT
Maximizing Magento: Getting the Most out of Promotions
PDF
Vortrag über Magento auf der InternetWorld 2008
PPT
Selecting the 'Right' eCommerce Plaform
PPT
Magento eCommerce And The Next Generation Of PHP
Driving Business Innovation with Magento
Best Practices for Launching an Enterprise Business on Magento
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
Magento's Imagine eCommerce Conference: Do You Queue?
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
Magento performancenbs
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Getting from Here to There: How to assess your business, define an overall eC...
Magento Imagine eCommerce, Day 2, Yoav Kutner CTO
Optimizing Magento Performance with Zend Server
Magento Roy Rubin Amsterdam Presentation
Maximizing Magento: Getting the Most out of Multi-Store Management
Maximizing Magento: Getting the Most out of Promotions
Vortrag über Magento auf der InternetWorld 2008
Selecting the 'Right' eCommerce Plaform
Magento eCommerce And The Next Generation Of PHP

Recently uploaded (20)

PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Approach and Philosophy of On baking technology
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Approach and Philosophy of On baking technology
GamePlan Trading System Review: Professional Trader's Honest Take
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...

Best Practices for Magento Debugging

  • 2. OVERVIEW •  Environment configuration •  Common Magento development problems and how to approach them •  Using the right tools for the job: PHP debugging and profiling with Magento/ Eclipse I won’t be covering everything in minute detail. At the end of the presentation, I’ll provide a link to slideshow and link to blog posts explaining different sections in more detail.
  • 4. AUTO-SET DEVELOPER MODE •  Enable Mage::isDeveloperMode() on development and staging environments •  Preferably, set the MAGE_IS_DEVELOPER_MODE via .htaccess file or server configuration. Example: •  Alternatively, set the developer mode using conditional code in index.php. Example:
  • 5. SHOW ALL ERRORS IN DEVELOPER MODE •  Ensure that all errors are displayed when in developer mode:
  • 6. WHY DETAILED ERROR AND EXCEPTION BACKTRACES ROCK •  You can see all arguments passed to functions in the call stack •  You can see all local variables at the location of the error/exception •  You can customize xdebug to create links that allow you to jump to a specific line/ file in your favorite editor HOW DO I GET SUCH DETAIL? •  Install Xdebug (an Apache module) on your development/staging servers •  My recommended xdebug configuration values: http://bit.ly/gspkIK
  • 8. After Links to the location the file Fully expanded argument variables Local variables
  • 9. HACK MAGENTO (SAFELY) TO ENABLE BACKTRACES •  Modify the Mage::run() method to not catch exceptions if developer mode is on (blog post explaining how to make this modification: http://bit.ly/feJE2y)
  • 10. USING MAGE::LOG TO LOG DEBUG DATA •  Mage::log() allows you to log code to either the default var/logs/system.log file, or a custom file. •  Mage::log(‘This is a custom message’, Zend_Log::INFO, ‘customfile.log’, true) •  Pass Varien_Debug::backtrace(true, false) to Mage::log() to log a backtrace. This is helpful if you want to know what code is calling a specific section of code. This can be helpful when testing methods that are difficult to use a debugger on, such as Paypal code. •  Log the attributes of a model using Mage::log($model->debug()) The debug() method prevents Mage::log from logging the dump of all of the nested objects •  You can monitor the contents of the log files using: •  Command-line: tail –f <file_name> •  Mac: Console.app (Must have developer tools installed) •  Windows: Baretail (http://www.baremetalsoft.com/baretail/ )
  • 11. CONFIGURE EXCEPTION HANDLER TO EMAIL REPORTS •  When a user of a live site encounters an error, Magento shows them a form (NOTE: on what conditions will Magento show a form vs a generic exception page) allowing them to submit the details that happened that caused that error. That exception will also be logged to var/log/exceptions.log •  If you want to be notified about all exceptions via email, copy errors/ local.xml.template to errors/local.xml and configure it to send reports via email and enter your email.
  • 13. GET TO THE BOTTOM OF THE SQLSTATE ERRORS •  What do you do when Magento throws a generic SQLSTATE database error? •  An “Integrity contraint violation”, or some other SQLSTATE error, doesn’t tell you much, unless you can view the error and the backtrace •  Especially relevant for errors encountered in the admin panel •  We have to hack two files (these hacks are harmless)…
  • 14. GET TO THE BOTTOM OF THE SQLSTATE ERRORS Modify Zend_Db_Adapter_Pdo_Abstract to get backtraces for single queries
  • 15. GET TO THE BOTTOM OF THE SQLSTATE ERRORS Modify Zend_Db_Statement_Pdo to get backtraces for transactional query errors
  • 16. THINGS TO CHECK WHEN A CUSTOM MODULE DOESN’T LOAD Problem: You’ve created a basic skeleton of a module with a module xml file, config.xml file, layout file, and block, but the module isn’t showing. Here are some quick steps you can take to debug the issue: 1.  Ensure that the module’s xml file in app/etc/modules/ is being loaded. Tip: Add an error to the module’s config file and then reload the page. If the page throws an error, the file is being loaded. 2.  Ensure that the module’s config.xml file is being loaded using same technique above 3.  Ensure that the layout file is getting loaded using same technique above 4.  Ensure that caching is disabled and remove the cache directory (var/cache) manually if it isn’t 5.  If you’re not working on a case-sensitive partition, ensure the cases of your class names and xml references are correct.
  • 17. DEBUGGING BY PROCESS OF ELIMINATION Problem: You are working on a site with 5 third-party modules and 4 custom modules. You’ve heavily modified the way that products work in the system. You run into an error where products aren’t saving from the admin. •  You can either: •  Start digging into the code to determine the cause of the issue, OR: •  Isolate the cause of the issue by progressively disabling the modules on the site until you identify which module is causing the error. Most of the time, this is the better approach. •  After you identify the violating module, start commenting out different sections of the config.xml file until the issue goes away. •  After you identify the bad class/file, go through the code, progressively eliminating different sections until you narrow it down to a line of code
  • 18. ESOTERIC ERROR MESSAGE Problem: Your client tries to place an order in the admin. When doing so, they get a generic error message about the product stock quantity not being able to be saved (NOTE: replace with real example, preferably one that can be recreated easily). You check the error and exception logs, but you have nothing to work with. What do you do? •  Take the error message and search the Magento codebase for the error. •  Once you locate the error, set a breakpoint and debug the error from there.
  • 19. DISABLING A MODULE VS DISABLING BLOCK OUTPUT •  Disabling block output explained •  You can access this option in System > Configuration > Advanced •  Disabling a module’s block output makes the XXXX class not output the contents of any blocks in that module •  Why would you disable a modules block output as opposed to disabling it? •  NOTE: Fill in details •  Core Magento classes that are commonly disabled •  Mage_Poll, Mage_Review, Mage_Tag, Mage_Wishlist (NOTE: Need to verify that there are no issues disabling these module‘s block output) •  Disabling a module •  Change the <active>true</active> to false •  Remove the module’s config file from app/etc/modules
  • 21. QUICK TIPS: DEBUGGING SHIPPING METHOD RATES •  Problem: Your shipping rates are configured like they should be, but when you add certain items to your cart, the shipping section is showing an error message like “No shipping rates found”. Magento provides no easy way to see what errors the carriers are returning, and so these errors can be hard to debug. •  Modify the classes in app/code/core/Mage/Usa/Model/Shipping/Carrier/ <carrier_name>.php to log XML returned from carrier •  UPS: Filename, line number •  Fedex: Filename, line number •  USPS: Filename, line number •  Once you have the full XML response data from the carrier, you can determine the cause of the error. •  Common causes: •  The products in the cart have 0 weight •  NOTE: Add additional items…
  • 22. DON’T BE AFRAID TO HACK - TEMPORARILY •  Find the source of the problem •  Set a debug point, or add a Mage::log() function to log the important data
  • 24. OVERVIEW OF ECLIPSE DEBUGGING •  Breakpoints / conditional breakpoints •  Stepping through code •  Inspecting variables in local scope (especially relevant are the _data and _items arrays on models and collections) •  Jumping back through the Call Stack to view variables in scope at that point in the stack •  Watch expressions •  Tip: Run code in current context using “Inspect”
  • 25. BREAKPOINTS •  Purposes •  Identify that Magento is hitting a certain section of code (can also use Mage::log(__METHOD__ . ‘ ‘ . __LINE); for that) •  Determine what a certain section of code does •  Conditional breakpoints SWITCH TO ECLIPSE FOR WALKTHROUGH
  • 26. INSPECTING VARIABLES •  Inspecting variables in local scope •  Many classes in Magento have recursive properties, so if you expand all properties, you’ll get an infinite nesting •  The _data array stores all of the data present in a model •  The _items array contains all of the items loaded in a collection SWITCH TO ECLIPSE FOR WALKTHROUGH
  • 27. CALL STACK •  Shows all code that has been run up to that point •  Clicking to previous lines in the call stack changes the variables in the local scope SWITCH TO ECLIPSE FOR WALKTHROUGH
  • 28. WATCH EXPRESSIONS •  See what a certain expression would return if it was being run in the code at that point. Example: $product->getStatus(); •  Run code in current context using “Inspect” •  Use Ctl+Shift+I to run code in local scope SWITCH TO ECLIPSE FOR WALKTHROUGH
  • 30. ZEND STUDIO-ONLY FEATURES •  Comparison between PDT and Zend Studio •  For debugging, the biggest advantages of Zend Studio are: •  Profiling •  Tight Zend Server integration (helpful if Magento site is running on Zend Server in production) SWITCH TO Zend Studio FOR WALKTHROUGH