Get Order Data

<?php
...
$order = Mage::getModel('sales/order')->load($orderId);
...

quote = cart contents in Magento. Theoretically the quote is an offer and if the user accepts it (by checking out) it converts to order. You can control the lifetime yourself and they store metadata about the store, totals information , shipping and billing relations, relations to payment method and shipping method (that is quoted separately) and items

What does in XML mean?

CDATA stands for Character Data and it means that the data in between these strings includes data that could be interpreted as XML markup, but should not be.

Example:
etc/system.xml

...
<comment><![CDATA[In kilometers]]></comment>
...

Dump SQL Query

Magento objects dump SQL on __toString() magic method call.

Official PHP Documentation describes aforementioned magic method as follows:
The __toString() method allows a class to decide how it will react when it is treated like a string. For example, what echo $obj; will print. This method must return a string, as otherwise a fatal E_RECOVERABLE_ERROR level error is emitted.

Zend_Debug::dump($stores->getSelect()->__toString())

SQL Query IN and NOT IN

Magento uses keywords in for IN and nin for NOT IN

...
 
$productIds = array(1251,1253,1256);
 
if ($column->getFilter()->getValue()) {
      $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
}
      else {
     $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
}
...

What is the difference of addAttributeToFilter() Vs addFieldToFilter()?

addAttributeToFilter() is used to filter EAV collections.

addFieldToFilter() is used to filter Non-EAV collections.

Re-use existing layout

tag is used for re-usage of existing layout

 
    <vendorname_modulename_constrollername_indexaction>
 
        <reference name="myreferencename">
            <block type="vendorname/blockname" name="modulename_blockname"
                   template="storelocator/template.phtml">
            </block>
        </reference>
 
    </vendorname_modulename_constrollername_indexaction>
 
    <vendorname_modulename_constrollername_listaction>
 
        <update handle="vendorname_modulename_constrollername_indexaction"/>
 
    </vendorname_modulename_constrollername_listaction>

Redirecting in Magento

Redirect to the list Action in the same Controller

$this->getResponse()->setRedirect(Mage::getUrl('*/*/list'));

How to get a table name in Magento Resource Collection

Method 1:

 
<?php
...
$this->getResource()->getTable('catalog/category_product');

Method 2:

 
...
Mage::getSingleton('core/resource')->getTableName('catalog/category_product');

Another method of getting Customer Data

 
<?php
 
...
    public function getCustomer()
    {
        $customerId = $this->_getCustomerId();
 
        return Mage::getModel('customer/customer')->load($customerId);
    }
 
    private function _getCustomerId() {
        return Mage::getSingleton('customer/session')->getCustomerId();
    }
...