Zend Anwar

Full stack web developer

Category: Magento

Magento

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

Read More

Which routers exist in a native Magento implementation?

– admin, – standard, – cms, – default

Read More

Get All Children Of A Block in Magento

Sorted: $this->getSortedChildren() Unsorted: $this->getChild()

Read More

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.

Read More

How to disable product tag in Magento

Just follow below instruction. System > Configuration > Advanced > Advanced > Mage_Tag – Disable

Read More

Magento review count of product

<?php echo $review_count = $_product->getRatingSummary()->getReviewsCount() ?>

Read More

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’) ?>  

Read More

Product status check in Magento

$stock _status =  $_product->getStockItem(); if ($stock_status->getIsInStock()) { echo ” in stock”; } else { echo “out of stock”; }

Read More

Get Category URL from Category ID in Magento

Very simple job, just follow below code $cat_id = 3; // predefined category ID echo cat_url = Mage::getModel(“catalog/category”)->load($cat_id)->getUrl();  

Read More

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

Read More