SlideShare ist ein Scribd-Unternehmen logo
1 von 48
OVERVIEW
•   Environment configuration
•   PHP debugging with Magento/Eclipse
•   Common Magento development problems
•   Mage::log()
•   Quick tips
The Imagine Conference has been excellently
   planned, but… they made one fatal mistake…




One important detail: My name is   Erik
   Hansen
Erik != Eric
ENABLE 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:
SHOW ALL ERRORS IN DEVELOPER MODE
•   Modify index.php with this conditional code to ensure that all errors are
    displayed when in developer mode:
NATIVE MAGENTO EXCEPTIONS
vs. XDEBUG EXCEPTIONS
                                            Links to the
                                          location the file



                              Fully
                            expanded
                            argument
                            variables




Local variables
INSTALL XDEBUG
•   Install Xdebug (an Apache module) on your development/staging
    servers
•   My recommended xdebug configuration values: http://bit.ly/gspkIK
MODIFY THE Mage CLASS
  •   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)
MODIFY THE Mage_Core_Model_App CLASS
  •   Modify the Mage_Core_Model_App::setErrorHandler() method to not set
      an error handler if developer mode is on (blog post explaining how to
      make this modification: http://bit.ly/co1qc4 )
CONFIGURE EXCEPTION HANDLER TO EMAIL REPORTS
ON A PRODUCTION SITE
 •   Optimize the way that
     exceptions are handled on a
     production site
 •   Configure Magento to send
     email upon every exception
BASIC XDEBUG/ECLIPSE SETUP
    •   Xdebug – Use config setting from previous slide
    •   Eclipse – Follow configuration instructions below:




1




2
Link to video: http://www.youtube.com/watch?v=6AynpmjW5us
UNCOVER THE SOURCE OF SQLSTATE ERRORS

•   What do you do when Magento throws a generic SQLSTATE database
    error?
UNCOVER THE SOURCE OF SQLSTATE ERRORS
• Example log file from SQLSTATE error


                                 Faulty SQL   SQL error
                                   query      message




                  Backtrace up
                   to point of
                   exception
UNCOVER THE SOURCE OF SQLSTATE ERRORS
• Modify Zend_Db_Adapter_Pdo_Abstract to get backtraces for single queries.
• Copy to app/code/local/Zend/Db/Adapter/Pdo/Abstract.php
UNCOVER THE SOURCE OF SQLSTATE ERRORS
• Modify Zend_Db_Statement_Pdo to get backtraces for transactional query
  errors
• Copy to app/code/local/Zend/Db/Adapter/Pdo/Abstract.php
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,       2
layout file, and block, but the module isn’t
showing. Here are some quick steps you can
take to debug the issue:




                                                          3




                                                  1
DEBUGGING BY PROCESS OF ELIMINATION
Problem: You are working on a site with 5 third-party modules and 9
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:
     • Work backward by reading code OR:
     • Isolate the issue by disabling modules
DEBUGGING BY PROCESS OF ELIMINATION
• Disable all custom modules, then selectively re-enable modules until you’ve
  found the problematic module

     1                               2                              3
DEBUGGING BY PROCESS OF ELIMINATION
• Once the offending module is identified, comment out sections of
config.xml to determine component that is causing the error


    1                               2                                3
VAGUE ERROR MESSAGE
    Problem: Your client tries to place an order in the admin. When doing so,
       they get a generic error message about the “The product could not be
       found”. You check the error and exception logs, but you have nothing
       to work with. What do you do?


1




      2




3
DISABLING A MODULE VS DISABLING BLOCK OUTPUT




                         V
                         S
WHEN COLLECTIONS DON’T LOAD THE ITEMS YOU WANT
•   $collection->load(true, true); logs the query to system.log and prints it to
    screen




• You can then use that query in a SQL tool to see why items aren’t loading




• Reference this Knowledge Base article for tips on collections: http://bit.ly/h0itx6
A MODEL/BLOCK/HELPER REWRITE WON’T WORK…
•   Is another module trying to override the same model/block/helper that
    you’re trying to override?
USING MAGE::LOG – BASIC EXAMPLE
•   Logging is disabled by default.
    Enable it in Configuration >
    Developer > Log Settings




•   Mage::log() allows you to log code to either the default
    var/logs/system.log file, or a custom file.




•   Message gets logged to var/logs/customfile.log
USING MAGE::LOG – NOTIFICATIONS/ERROR NOTICES
USING MAGE::LOG – LOGGING API RESPONSES
View XML/CGI responses from API calls, like shipping quote requests
USING MAGE::LOG –DETERMINE CODE COVERAGE
Find out if a certain line of code is getting reached. Alternative to using
   debugger.
USING MAGE::LOG – VIEWING LOG DATA
•    You can monitor the contents of the log files using:
    • Command-line: tail –f <file_name>
    • OS X: Console.app (Must have developer tools installed)
    • Windows: Baretail (http://www.baremetalsoft.com/baretail/ )
CHECK THE BUG TRACKER / FORUMS
•   Someone may have already solved your problem
•   If the bug tracker has marked an item as resolved, look in the comments
    for a code patch, or the SVN trunk
WILL A NEWER VERSION OF MAGENTO FIX THE
ISSUE AT HAND?
•   Setup upgrade environment and do a quick upgrade to latest production
    release to see if that solves the issue
ISOLATE CODE IN A “SANDBOX.PHP” FILE
•   Allows you to run code outside of the context of a controller/page
•   Copy index.php to sandbox.php
•   Modify Mage::run to Mage::app
GENERAL ADVICE
•   Don’t get stuck in a certain way of solving problems.
•   Read (and understand) the code
•   Before delving into a problem headlong, take a step back and think
    holistically about the problem
QUESTIONS?
OPTIMIZING BUGGY/SLOW CODE W/ VARIEN_PROFILER

   •   Find out what events are getting triggered on a page
   •   How many times is your custom code running?
   •   Optimize slow code
STANDARD MAGENTO PROFILE (OUTPUT IN HTML TABLE)
•   You must enable profiler in System > Configuration > Developer > Profile
CUSTOM MAGENTO PROFILE (OUTPUT TO LOG FILE)
• Modify index.php




1




2



           Profile gets logged to var/log/profiler.log

3
CUSTOMIZED PROFILE THAT EXTENDS NATIVE PROFILE WITH
MYSQL QUERIES

•   Read about how to implement this on Branko Ajzele’s blog:
    http://bit.ly/geMSrT
CONCLUSION
•   Code samples referenced in slides available here: http://bit.ly/dNNgxU
•   Eclipse walkthrough video:
    http://www.youtube.com/watch?v=6AynpmjW5us

Weitere ähnliche Inhalte

Was ist angesagt?

S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaAgile Testing Alliance
 
Oracle Forms: create debug triggers
Oracle Forms: create debug triggersOracle Forms: create debug triggers
Oracle Forms: create debug triggersSekhar Byna
 
Top 50 Interview Questions and Answers in CakePHP
Top 50 Interview Questions and Answers in CakePHPTop 50 Interview Questions and Answers in CakePHP
Top 50 Interview Questions and Answers in CakePHPKetan Patel
 
Maven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working TogetherMaven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working TogetherCarlos Sanchez
 
Take Your XPages Development to the Next Level
Take Your XPages Development to the Next LevelTake Your XPages Development to the Next Level
Take Your XPages Development to the Next Levelbalassaitis
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenGeert Pante
 
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Session on Selenium 4 : What’s coming our way? by Hitesh PrajapatiSession on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Session on Selenium 4 : What’s coming our way? by Hitesh PrajapatiAgile Testing Alliance
 
Q4E and Eclipse IAM, Maven integration for Eclipse
Q4E and Eclipse IAM, Maven integration for EclipseQ4E and Eclipse IAM, Maven integration for Eclipse
Q4E and Eclipse IAM, Maven integration for EclipseCarlos Sanchez
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpodilodif
 
Maven plugin guide using Modello Framework
Maven plugin guide using Modello FrameworkMaven plugin guide using Modello Framework
Maven plugin guide using Modello Frameworkfulvio russo
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with SeleniumYuriy Gerasimov
 
Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...Agile Testing Alliance
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introductionSagar Verma
 

Was ist angesagt? (17)

S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Oracle Forms: create debug triggers
Oracle Forms: create debug triggersOracle Forms: create debug triggers
Oracle Forms: create debug triggers
 
Java and XPages
Java and XPagesJava and XPages
Java and XPages
 
Top 50 Interview Questions and Answers in CakePHP
Top 50 Interview Questions and Answers in CakePHPTop 50 Interview Questions and Answers in CakePHP
Top 50 Interview Questions and Answers in CakePHP
 
Maven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working TogetherMaven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working Together
 
Take Your XPages Development to the Next Level
Take Your XPages Development to the Next LevelTake Your XPages Development to the Next Level
Take Your XPages Development to the Next Level
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in Maven
 
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Session on Selenium 4 : What’s coming our way? by Hitesh PrajapatiSession on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
 
Q4E and Eclipse IAM, Maven integration for Eclipse
Q4E and Eclipse IAM, Maven integration for EclipseQ4E and Eclipse IAM, Maven integration for Eclipse
Q4E and Eclipse IAM, Maven integration for Eclipse
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
Maven plugin guide using Modello Framework
Maven plugin guide using Modello FrameworkMaven plugin guide using Modello Framework
Maven plugin guide using Modello Framework
 
Why gradle
Why gradle Why gradle
Why gradle
 
Maven
MavenMaven
Maven
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with Selenium
 
Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introduction
 

Ähnlich wie Magento Imagine 2011 - Magento Debugging - Erik Hansen, Classy Llama Studios

Best Practices for Magento Debugging
Best Practices for Magento Debugging Best Practices for Magento Debugging
Best Practices for Magento Debugging varien
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsDana Luther
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN ControllerSumit Arora
 
Oracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11gOracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11guzzal basak
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Jess Coburn
 
Introduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformIntroduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformJarne W. Beutnagel
 
Troubleshooting mule
Troubleshooting muleTroubleshooting mule
Troubleshooting muleSon Nguyen
 
Zendcon magento101
Zendcon magento101Zendcon magento101
Zendcon magento101Mathew Beane
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudLyzun Oleksandr
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortalscgack
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernizationdevObjective
 
WebObjects Developer Tools
WebObjects Developer ToolsWebObjects Developer Tools
WebObjects Developer ToolsWO Community
 
Dolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in ValenceDolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in ValenceLaurent Destailleur
 
Care and Feeding of Large Web Applications
Care and Feeding of Large Web ApplicationsCare and Feeding of Large Web Applications
Care and Feeding of Large Web ApplicationsPerrin Harkins
 

Ähnlich wie Magento Imagine 2011 - Magento Debugging - Erik Hansen, Classy Llama Studios (20)

Best Practices for Magento Debugging
Best Practices for Magento Debugging Best Practices for Magento Debugging
Best Practices for Magento Debugging
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
Oracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11gOracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11g
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11
 
Introduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformIntroduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce Platform
 
Agility Requires Safety
Agility Requires SafetyAgility Requires Safety
Agility Requires Safety
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
Troubleshooting mule
Troubleshooting muleTroubleshooting mule
Troubleshooting mule
 
Zendcon magento101
Zendcon magento101Zendcon magento101
Zendcon magento101
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 
Lug
LugLug
Lug
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortals
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
Magento++
Magento++Magento++
Magento++
 
WebObjects Developer Tools
WebObjects Developer ToolsWebObjects Developer Tools
WebObjects Developer Tools
 
Dolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in ValenceDolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in Valence
 
Care and Feeding of Large Web Applications
Care and Feeding of Large Web ApplicationsCare and Feeding of Large Web Applications
Care and Feeding of Large Web Applications
 

Kürzlich hochgeladen

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Kürzlich hochgeladen (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Magento Imagine 2011 - Magento Debugging - Erik Hansen, Classy Llama Studios

  • 1.
  • 2. OVERVIEW • Environment configuration • PHP debugging with Magento/Eclipse • Common Magento development problems • Mage::log() • Quick tips
  • 3. The Imagine Conference has been excellently planned, but… they made one fatal mistake… One important detail: My name is Erik Hansen
  • 5.
  • 6. ENABLE 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:
  • 7. SHOW ALL ERRORS IN DEVELOPER MODE • Modify index.php with this conditional code to ensure that all errors are displayed when in developer mode:
  • 9. vs. XDEBUG EXCEPTIONS Links to the location the file Fully expanded argument variables Local variables
  • 10. INSTALL XDEBUG • Install Xdebug (an Apache module) on your development/staging servers • My recommended xdebug configuration values: http://bit.ly/gspkIK
  • 11. MODIFY THE Mage CLASS • 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)
  • 12. MODIFY THE Mage_Core_Model_App CLASS • Modify the Mage_Core_Model_App::setErrorHandler() method to not set an error handler if developer mode is on (blog post explaining how to make this modification: http://bit.ly/co1qc4 )
  • 13. CONFIGURE EXCEPTION HANDLER TO EMAIL REPORTS ON A PRODUCTION SITE • Optimize the way that exceptions are handled on a production site • Configure Magento to send email upon every exception
  • 14.
  • 15. BASIC XDEBUG/ECLIPSE SETUP • Xdebug – Use config setting from previous slide • Eclipse – Follow configuration instructions below: 1 2
  • 16. Link to video: http://www.youtube.com/watch?v=6AynpmjW5us
  • 17.
  • 18. UNCOVER THE SOURCE OF SQLSTATE ERRORS • What do you do when Magento throws a generic SQLSTATE database error?
  • 19. UNCOVER THE SOURCE OF SQLSTATE ERRORS • Example log file from SQLSTATE error Faulty SQL SQL error query message Backtrace up to point of exception
  • 20. UNCOVER THE SOURCE OF SQLSTATE ERRORS • Modify Zend_Db_Adapter_Pdo_Abstract to get backtraces for single queries. • Copy to app/code/local/Zend/Db/Adapter/Pdo/Abstract.php
  • 21. UNCOVER THE SOURCE OF SQLSTATE ERRORS • Modify Zend_Db_Statement_Pdo to get backtraces for transactional query errors • Copy to app/code/local/Zend/Db/Adapter/Pdo/Abstract.php
  • 22. 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, 2 layout file, and block, but the module isn’t showing. Here are some quick steps you can take to debug the issue: 3 1
  • 23. DEBUGGING BY PROCESS OF ELIMINATION Problem: You are working on a site with 5 third-party modules and 9 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: • Work backward by reading code OR: • Isolate the issue by disabling modules
  • 24. DEBUGGING BY PROCESS OF ELIMINATION • Disable all custom modules, then selectively re-enable modules until you’ve found the problematic module 1 2 3
  • 25. DEBUGGING BY PROCESS OF ELIMINATION • Once the offending module is identified, comment out sections of config.xml to determine component that is causing the error 1 2 3
  • 26. VAGUE ERROR MESSAGE Problem: Your client tries to place an order in the admin. When doing so, they get a generic error message about the “The product could not be found”. You check the error and exception logs, but you have nothing to work with. What do you do? 1 2 3
  • 27. DISABLING A MODULE VS DISABLING BLOCK OUTPUT V S
  • 28. WHEN COLLECTIONS DON’T LOAD THE ITEMS YOU WANT • $collection->load(true, true); logs the query to system.log and prints it to screen • You can then use that query in a SQL tool to see why items aren’t loading • Reference this Knowledge Base article for tips on collections: http://bit.ly/h0itx6
  • 29. A MODEL/BLOCK/HELPER REWRITE WON’T WORK… • Is another module trying to override the same model/block/helper that you’re trying to override?
  • 30.
  • 31. USING MAGE::LOG – BASIC EXAMPLE • Logging is disabled by default. Enable it in Configuration > Developer > Log Settings • Mage::log() allows you to log code to either the default var/logs/system.log file, or a custom file. • Message gets logged to var/logs/customfile.log
  • 32. USING MAGE::LOG – NOTIFICATIONS/ERROR NOTICES
  • 33. USING MAGE::LOG – LOGGING API RESPONSES View XML/CGI responses from API calls, like shipping quote requests
  • 34. USING MAGE::LOG –DETERMINE CODE COVERAGE Find out if a certain line of code is getting reached. Alternative to using debugger.
  • 35. USING MAGE::LOG – VIEWING LOG DATA • You can monitor the contents of the log files using: • Command-line: tail –f <file_name> • OS X: Console.app (Must have developer tools installed) • Windows: Baretail (http://www.baremetalsoft.com/baretail/ )
  • 36.
  • 37. CHECK THE BUG TRACKER / FORUMS • Someone may have already solved your problem • If the bug tracker has marked an item as resolved, look in the comments for a code patch, or the SVN trunk
  • 38. WILL A NEWER VERSION OF MAGENTO FIX THE ISSUE AT HAND? • Setup upgrade environment and do a quick upgrade to latest production release to see if that solves the issue
  • 39. ISOLATE CODE IN A “SANDBOX.PHP” FILE • Allows you to run code outside of the context of a controller/page • Copy index.php to sandbox.php • Modify Mage::run to Mage::app
  • 40. GENERAL ADVICE • Don’t get stuck in a certain way of solving problems. • Read (and understand) the code • Before delving into a problem headlong, take a step back and think holistically about the problem
  • 42.
  • 43. OPTIMIZING BUGGY/SLOW CODE W/ VARIEN_PROFILER • Find out what events are getting triggered on a page • How many times is your custom code running? • Optimize slow code
  • 44. STANDARD MAGENTO PROFILE (OUTPUT IN HTML TABLE) • You must enable profiler in System > Configuration > Developer > Profile
  • 45. CUSTOM MAGENTO PROFILE (OUTPUT TO LOG FILE)
  • 46. • Modify index.php 1 2 Profile gets logged to var/log/profiler.log 3
  • 47. CUSTOMIZED PROFILE THAT EXTENDS NATIVE PROFILE WITH MYSQL QUERIES • Read about how to implement this on Branko Ajzele’s blog: http://bit.ly/geMSrT
  • 48. CONCLUSION • Code samples referenced in slides available here: http://bit.ly/dNNgxU • Eclipse walkthrough video: http://www.youtube.com/watch?v=6AynpmjW5us

Hinweis der Redaktion

  1. • Been doing Magento development for three years. Have come up with ways to more efficiently solve problems and solve bugs. Want to share them with you all.
  2. 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.It will be a bit randomSome of you will know this stuff
  3. They even used my slideshow colors
  4. • If you have a dedicated stage/dev server, you should setup a global environment variable in your server’s config• Benefit of second method is that you can deploy one codebase without having to change .htaccess file on independent servers.
  5. • This is elementary, but you want to display errors only on dev/stage environments•Sometimes you have issues with E_NOTICE being turned on, during the checkout and possibly some places in the admin
  6. You can see all arguments passed to functions in the call stackYou can see all local variables at the location of the error/exceptionYou can customize xdebug to create links that allow you to jump to a specific line/file in your favorite editor
  7. • Any time you modify core files, have a standard comment notation so you can search codebase for all edits• Make joke about hacking the core
  8. Use case: You’ve launched a site in production or staging. Users get errors. You either have to check var/logs/exceptions.log on a regular basis, or you can setup to get emailed with these notifications so that you can preempt a store owner contacting you about an issue.This should only be setup this way on a production site. On a development site, you should use xdebug’s exception handling.• Copy errors/local.xml.template to errors/local.xml• The generated exception will be logged to var/log/exceptions.log
  9. Use cases for debugging:• Understanding how the core system works• Determining non-obvious bugs in your code – ie, bugs that don’t throw errors/exceptions
  10. Eclipse = PDT or Zend Studio
  11. • Example errors: Lock wait timeout, integrity constraint errors, out of memory, etc...Especially relevant for errors encountered in the admin panel Modify (harmlessly) two files
  12. Check if the module’s xml file is loading Create a syntax errorCheck if the module’s config.xml file is loadingCheck if the layout file is loadingMake sure caching is disabled remove the cache directory if it exists (var/cache)
  13. A completely different approach than jumping directly into the code. Helps isolate the problem
  14. •Copy the error messageSearch the Magento codebase for the errorOnce you locate the error, set a breakpointUse debug tools to discover the cause of the error
  15. Disabling block output explainedYou can access this option in System &gt; Configuration &gt; AdvancedDisabling a module’s block output makes the XXXX class not output the contents of any blocks in that moduleWhy would you disable a modules block output as opposed to disabling it? NOTE: Fill in detailsCore Magento classes that are commonly disabledMage_Poll, Mage_Review, Mage_Tag, Mage_Wishlist (NOTE: Need toverifythattherearenoissuesdisablingthesemodule‘s block output)Disabling a moduleChange the &lt;active&gt;true&lt;/active&gt; to falseRemove the module’s config file from app/etc/modules
  16. 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
  17. Preventative method of doing development
  18. TODO: Include example output
  19. Example: Once you get familiar with a debugger, it’s easy to resort to debugging without first reading through the code, checking the bug tracker, etc…Get up, go get a drink, etc… I’ve had more epiphanies about how to solve problems when going pee than anyplace else
  20. Events &amp; their observers, controller dispatches, model loads, etc…
  21. Useful for Ajax, Paypal responses, API calls, etc…
  22. • Useful to determine what your queries look like• If a collection isn’t loading, look at and analyze the query