Sunday, July 15, 2012

Magento Debugging tips

Here are some Debugging tips which will help to debug magneto code.As some of the tools are also availiable which will help to debug the code easily 

There is one free extension availiable for the Debugging the code ,files,DB .....click on the following link 


1) If variable is object and of which class
<?php Zend_Debug::dump(get_class($this), 'get_class') ?>

2) If variable to see its content/value
<?php Zend_Debug::dump($this->debug(), 'debug') ?>

3) If read the value of object properties/attributes
For example we will use $_product
 <?php Zend_Debug::dump($_product->getData('attribute_name')) ?>

4) If Loop trough Magento collection object
(Check if something is a collection, if we can iterate trough it)
<?php if($var instanceof Varien_Data_Collection): ?>
    <ul>
    <?php foreach($var as $k => $v): ?>
        <li>Some value: <?php echo $v ?></li>
    <?php endforeach; ?>
    </ul>
<?php endif; ?>

5) If to get the files which are included in that page
print_r(get_included_files());

6) If to get the full list of methods available
get_class_methods
hope this will help you

No comments:

Post a Comment

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...