Explain life cycle of a Block in Magento

_prepareLayout() method is called immediately after a block has been added to the layout object for the first time. _beforeToHtml() method is called immediately before a block’s HTML content is rendered. _afterToHtml() method is called immediately after a block’s HTML content is generated. _beforeChildToHtml() is called when a parent renders one of its children (through a call to $this->getChildHtml(‘name’)).

Continue Reading

How to show stock status in shopping cart in Magento

It is very simple. Please add a <th> Stock Status </th> filed in default\template\checkout\cart.phtml and go to \default\template\checkout\cart\item\default.phtml <?php $_product= Mage::getSingleton(‘catalog/product’)->load($_item->getProductId()); ?> <td class=”a-center”> <span calss=”stock-cart”>  <?php $qty = $_product->getStockItem()->getQty(); if($qty > 0){ echo “In stock”; }else{ echo “Out of stock”; } ?></span> </td> Hope so it will work.

Continue Reading

How to add review form in product details page custom tab in Magento

Please add below code in your local.xml .  This file system for Magento EE. <catalog_product_view> <!–Product Information Block–> <reference name=”root”> <reference name=”product.info”> <block type=”review/product_view_list” name=”product.info.product_additional_data” as=”product_additional_data_review” template=”review/product/view/list.phtml” /> <block type=”review/form” name=”product.review.form” as=”review_form” /> </reference> </catalog_product_view>   call below code in your product view file. <?php echo $this->getChildHtml(‘review_form’) ?> <?php echo $this->getChildHtml(‘product_additional_data_review’) ?>  

Continue Reading

Magento Events List

Magento uses a fantastic event hooking system, following the Observer Design Pattern, allowing additional functionality to be plugged in and out without modifying the core code. Core File Line Event /app/code/core/Mage/Admin/Model/Session.php 104 admin_session_user_login_success /app/code/core/Mage/Admin/Model/Session.php 112 admin_session_user_login_failed /app/code/core/Mage/Admin/Model/User.php 337 admin_user_authenticate_before /app/code/core/Mage/Admin/Model/User.php 354 admin_user_authenticate_after /app/code/core/Mage/Adminhtml/Block/Api/User.php 52 api_user_html_before /app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php 160 adminhtml_catalog_category_edit_prepare_form /app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php 157 adminhtml_catalog_category_tabs /app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php 291 adminhtml_catalog_category_tree_is_moveable /app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php 328 adminhtml_catalog_category_tree_can_add_root_category /app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php 348 adminhtml_catalog_category_tree_can_add_sub_category …

Continue Reading