Magento: Resize Image

You can resize image with fixed height and variable width. Or, you can resize with fixed width and variable height. Following code shows how you do it in Magento. Fixed width of 600px <?php echo $this->helper('catalog/image')->init($_product, 'image') ->constrainOnly(TRUE) ->keepAspectRatio(TRUE) ->keepFrame(FALSE) ->resize(600,null) ?> Fixed height of 600px <?php echo $this->helper('catalog/image')->init($_product, 'image') ->constrainOnly(TRUE) ->keepAspectRatio(TRUE) ->keepFrame(FALSE) ->resize(null,600) ?> … Read more

Magento: Get current URL of the page

Getting URL of a current page you are visiting or working on is a common requirement in any web development project. There are various ways you can get the current URL of a page in Magento. Here are some :- From Mage_Core_Helper_Url class $currentUrl = Mage::helper('core/url')->getCurrentUrl(); From Mage_Core_Model_Store class $currentUrl = Mage::app()->getStore()->getCurrentUrl(false); If you want … Read more

Magento: Format Price

When you fetch product data, you get the price as integer. Now, you have to display the price with currency suffix. You can format price with the following code. Let $_finalPrice be the integer price fetched. To display price with currency symbol: $formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false); // OR $formattedPrice = Mage::helper('core')->formatPrice($_finalPrice, false); To display price without … Read more

Magento: Get Set Unset Session

Here are code to Get, Set, and Unset Session in Magento. Set session with variable Name ‘testing_magento‘. The session value here is ‘hello‘. Mage::getSingleton(‘core/session’)->setTestingMagento(‘hello’); Get session ‘testing_magento’ $test = Mage::getSingleton(‘core/session’)->getTestingMagento(); Unset session Mage::getSingleton(‘core/session’)->setTestingMagento(); Note: Use customer or core session in frontend. Use adminhtml session in the backend. Core Session:- Mage::getSingleton(‘core/session’) Customer Session:- Mage::getSingleton(‘customer/session’) Admin Session:- … Read more

How to Install Sample Data for Magento?

Remember that, Sample Data must be installed prior to the basic Magento Installation. But never mind if you forgot to install sample data before installing Magento. Here, I will show you how you can install sample data after you have installed Magento. 1) Download Sample Data zip file from Magento Website 2) Extract the zip … Read more

Configuration error on new Magento installation

Scenario: < p style=”text-align: justify;”>I am installing a fresh magento 1.3.2.1 in my Windows XP computer. I have Xampp installed. While installing magento, I had a problem at the configuration step where I had to fill database host, username, password etc. When I click continue after filling the required fields, the installation process doesn’t move … Read more

PHP extension error while installing Magento

I was installing Magento 1.3.2.1 in my Windows XP computer. I am using Xampp. I encountered the following errors during the installation. < p style=”text-align: justify;”>PHP Extension “curl” must be loaded PHP Extension “mcrypt” must be loaded PHP Extension “pdo_mysql” must be loaded I googled and the answer was to load the extension in php.ini … Read more