Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save matheusgontijo/b2722a6322283e84006367d2849696ab to your computer and use it in GitHub Desktop.
Save matheusgontijo/b2722a6322283e84006367d2849696ab to your computer and use it in GitHub Desktop.
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Video: https://www.youtube.com/watch?v=xLf3OwpAFhQ
-----------------------------------------------
1) Track MySQL queries
vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php::query
vendor/magento/zendframework1/library/Zend/Db/Select.php
// stripos($sql, 'tablenamehere') !== false
Real World examples:
Example 01 | What is the query for "catalog_product_entity_varchar" table?
Example 02 | What is the query for "eav_attribute_option_value" table?
Example 03 | What is the query for "review_detail" table?
Example 04 | What is the query for "catalog_product_entity_media_gallery" table?
-----------------------------------------------
2) Track the queries result's
vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php
Methods:
- fetchAll (*) most used
- fetchRow (*) most used
- fetchAssoc
- fetchCol
- fetchPairs
- fetchOne
<?php
foreach ($result as $row) {
foreach ($row as $key => $value) {
$breakpoint = null; // is_scalar($value) && stripos($value, 'montana') !== false
}
}
?>
Real World examples:
Example 01 | Where is the "Montana Wind Jacket" product name is coming from?
Example 02 | Where is the "Purple"?
Example 03 | Where is the "talking about here" review description is coming from?
Example 04 | Where is the "mj03-black_back_1.jpg" image is coming from?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment