Zend Anwar

Full stack web developer

Category: Magento

Magento

How to create Featured product in Magento home page?

Create new Featured attribute Create a new attribute by going to Catalog > Attributes > Manage Attributes > Add New Attribute. Attribute Properties Attribute Identifier: featured Scope: Store View Catalog Input Type for Store Owner: Yes/No Unique Value (not shared with other products): No Values Required: No Input Validation for Store Owner: None Apply To: […]

Read More

Explain class naming conventions and their relationship with the autoloader

Magento was developed based on the Zend Framework, so the rules of class naming in Magento were taken from the Zend Framework (read more here). Magento standardizes class names depending on their location in the file system. Such standardization enables automatic class loading (autoloader) instead of using require_once and include_once functions. Rather than the directory […]

Read More

Describe Magento Codepools

Magento has three different codepools: Community Core Local Core pool First of all, this folder stores all the code that makes Magento so powerful, flexible and lovely. The chief rule of Magento development is that you should never make any changes in it. In other words, this folder belongs to Magento core developers only and […]

Read More

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 […]

Read More

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 […]

Read More

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 […]

Read More

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 […]

Read More

Which class is responsible for creating an instance of the block in Magento?

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 }

Read More

Is it possible to have a block without a template in Magento?

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.

Read More

How $this variable work inside the template file in Magento?

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.

Read More