Magento: Add jQuery tabs in CMS page

You can add tabs in a CMS page in Magento. I have used jQueryUI tabs for this purpose. You can view the examples and source code of the tabs feature here: http://jqueryui.com/tabs/ Here is the step-by-step guide to create tabs on Magento CMS page:- 1. Create a CMS page (CMS -> Pages -> Add New … Read more

Magento: Get Product by SKU

Here is a quick code to get / load product by its SKU in Magento. Generally we load product by its ID. Assuming product id to be ‘166’. $_productId = '166'; $_product = Mage::getModel('catalog/product')->load($_productId); But, we can also load product by its attributes, like SKU. Assuming product sku to be ‘logitechcord’. $_sku = 'logitechcord'; $_product … Read more

Magento: Get Add to Cart URL of any Product

Here is a quick code to get add to cart url of any product. Suppose that we are fetching add to cart url of a product with id ‘166’. $_productId = '166'; $_product = Mage::getModel('catalog/product')->load($_productId); $_url = Mage::helper('checkout/cart')->getAddUrl($_product); Hope it helps. Thanks.

Magento: Avoid Module/Extension Rewrite/Override Class Conflict

While developing Magento modules/extensions, we often come up with a case where our module and some other module are rewriting/overriding the same core class. Hence, we get a conflict here and either our module or the other module will not function as expected. There are some ways to avoid such conflicts. I will explain about … Read more

Magento: Use MySQL functions with addExpressionAttributeToSelect

Function addExpressionAttributeToSelect as defined in Mage_Eav_Model_Entity_Collection_Abstract (/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php) allows us to use MySQL functions in Magento collection. Here is an example of using MySQL function CONCAT in Magento customer collection to concat customer’s firstname and lastname: $collection = Mage::getResourceModel('customer/customer_collection') ->addExpressionAttributeToSelect('fullname', 'CONCAT({{firstname}}, " ", {{lastname}})', array('firstname','lastname')); Here is another example which uses MySQL function MONTH which fetches … Read more

Magento: www or non-www URL redirecting to homepage

Problem: You have a Magento website with Base URL = http://example.com/ Working: http://example.com/category-one.html Not working: http://www.example.com/category-one.html (redirecting to homepage) The only difference in the above two URLs is that the second URL has “www” in it. Similary, you may have another Magento website with Base URL = http://www.example.com/ In this case, Working: http://www.example.com/category-one.html Not working: … Read more

[SOLVED] Sorry, no quotes are available for this order at this time magento [Checkout Shipping Methods]

I just upgraded a Magento shop and I had problem on ‘Shipping Methods‘ sections of onepage checkout. No shipping methods were displayed and I was getting the following message over there: Sorry, no quotes are available for this order at this time magento I had enabled ‘Table Rates‘ shipping method. Solution: – Login to your … Read more

Magento Upgrade: Problems/Errors and Solutions

Here are solution to some errors that I faced while upgrade Magento. Error 1: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in downloader/pearlib/php/System.php on line 400 Solution: Edit file named ‘pear‘. This file is present on root folder of your Magento installation. Add the following lines at the beginning of file: MAGE_PEAR_PHP_BIN=/usr/local/bin/php5; export MAGE_PEAR_PHP_BIN Error 2: … Read more

Magento: Load multiple products at once

Suppose, you have ID of some products and you want to load them at once in Magento, then here is a solution:- Suppose, you have 5 products ID: 5, 22, 45, 75, 88 You can store them in one array: $productIds = array(5, 22, 45, 75, 88); Then, you can use MySQL’s IN() clause for … Read more