Blog: Extra-ordinary

Magento Sample Question & Answer

Q. How will you log current collection’s SQL query? A. $collection->printLogQuery(true); OR $collection->getSelect()->__toString(); Q. How to get first item or last item from the collection? A. $collection->getFirstItem() and $collection->getLastItem(); Q. Where is the relation between configurable product and it’s simple product stored in database? A. In the 2 tables: catalog_product_relation catalog_product_superlink_table Q. What are the commonly used block types? What …

Continue Reading

Mage_Core_Block_Text in Magento

It inherints directly from Mage_Core_Block_Abstract and extends its base class only with three methods: 1.  public function setText($text) 2.  public function addText($text, $before=false) {} 3.  public function getText() The block only stores a text string (it could be plain or html of course), and during rendering phase, the block simply outputs the stored string. You could set the string to …

Continue Reading

Mage_Core_Block_Template in Magento

The most important feature of this type of block is of course that you can asign it a template file for rendering. That template will be a file stored on the theme level, so we could say this block is maybe the base block for Magento support of themes. When the block it’s going to be rendered, Magento looks for …

Continue Reading

What is a difference in rendering process for different types of blocks in Magento?

Mage_Core_Block_Text : This is a simple text block so it is not usual that it has child. If so, they will not be automatically rendered, and you would need to render it manually in code. Mage_Core_Block_Template : Childs of template based block renders when calling getChildHtml from template file. The block should be defined as child either by layout directive …

Continue Reading