Magento Sample Question & Answer
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
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
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
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
-
zendnwar
-
March 18, 2015
-
Magento
-
1 Comment
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?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
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
Which class is responsible for creating an instance of the block in Magento?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
In Magento, the whole block hierarchy during a page generation is created by the class Mage_Core_Model_Layout. The method generateBlocks is responsible of that. public function generateBlocks($parent=null) { // some code here }
Continue Reading
Is it possible to have a block without a template in Magento?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
Of course yes… in fact, the only predefined block class in Magento that uses a template file is Mage_Core_Block_Template. It is the most used, but not the only block class in Magento. Other classes in Magento like Mage_Core_Block_Text or Mage_Core_Block_Text_List doesn’t use a template file.
Continue Reading
How $this variable work inside the template file in Magento?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
In Magento, the template file for each block is ‘included’ by a php include directive during the render phase, so it´s clear that $this inside a template file, always refer to the block class instance. The include is done in the fetchView() method of Mage_Core_Block_Template.
Continue Reading
What is the role of the Mage_Core_Block_Abstract class in Magento?
-
zendnwar
-
March 18, 2015
-
Magento
-
281 Comments
Mage_Core_Block_Abstract is the base class for all blocks in a Magento store and it provides basic functionallity for working with layout, block hierarchy (insert, remove childs…), output contents, and so on.
Continue Reading
Which class does each block that uses a template extend in Magento?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
Any Magento Block that uses a template file, inherits from Mage_Core_Block_Template which inherits from Mage_Core_Block_Abstract
Continue Reading
What is the parent block for all Magento blocks?
-
zendnwar
-
March 18, 2015
-
Magento
-
0 Comments
All Magento blocks inherits Mage_Core_Block_Abstract that inherits directly from Varien_Object
Continue Reading