Blog: Extra-ordinary

Track Visitor’s Information in Magento

<?php $visitorInfo = Mage::getSingleton(‘core/session’)->getVisitorData(); print_r($visitorInfo); // Array // ( // => // server_addr => 167772437 // remote_addr => 167772437 // http_secure => // http_host => 127.0.0.1 // http_user_agent => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) //AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10 // http_accept_language => en-US,en;q=0.8 // http_accept_charset => ISO-8859-1,utf-8;q=0.7,*;q=0.3 // request_uri => /magento/index.php/catalog/category/view/id/22 // session_id => 13qm5u80238vb15lupqcac97r5 // …

Continue Reading

Get products id, name, price, quantity, etc. present in your cart in Magento

<?php $items = Mage::getSingleton(‘checkout/session’)->getQuote()->getAllItems(); foreach($items as $item) { echo ‘ID: ‘.$item->getProductId().'<br />’; echo ‘Name: ‘.$item->getName().'<br />’; echo ‘Sku: ‘.$item->getSku().'<br />’; echo ‘Quantity: ‘.$item->getQty().'<br />’; echo ‘Price: ‘.$item->getPrice().'<br />’; echo “<br />”; } ?>

Continue Reading

getBaseUrl – Magento URL Path in Magento

<?php // http://domainname.com/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); // http://domainname.com/js/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); // http://domainname.com/index.php/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); // http://domainname.com/media/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); // http://domainname.com/skin/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>

Continue Reading

Get Current Store Details (ID, Code, Name and Status) in Magento

// Gets the current store’s details $store = Mage::app()->getStore(); // Gets the current store’s id $storeId = Mage::app()->getStore()->getStoreId(); // Gets the current store’s code $storeCode = Mage::app()->getStore()->getCode(); // Gets the current website’s id $websiteId = Mage::app()->getStore()->getWebsiteId(); // Gets the current store’s group id $storeGroupId = Mage::app()->getStore()->getGroupId(); // Gets the current store’s name $storeName = Mage::app()->getStore()->getName(); // Gets the current store’s …

Continue Reading

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: All Product Types Front End …

Continue Reading

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 separator (‘/’ – invalid character …

Continue Reading

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 if you are going to …

Continue Reading