Browsing articles in "Magento"
May 26, 2013

Magento performace optimization, Catalog URL Rewrite Management

If your Magento site is slow, then one of the reason can be because of Catalog URL Rewrites. You can check in the Magento Admin > Catalog > URL Rewrite Management. If you see the catalog rewrites are very large than expected as per total Categories and Products you have, this will create your site to be slow. This generally gets too large if you edit the categories/products and change it’s URL. Generally we keep on changing the product URL to optimize for search engines or to correct some typo in the link. Magento saves all the previous category and product URLs even if it is changed many times, resulting in more number of URL rewrites in database. I have seen in one of the project, where total SKUs were near to 4,00,000 while the URL Rewrites were near to 46,00,000 with just one website and store!

Magento Catalog URL Rewrite Management
Continue reading »

May 26, 2013

Magento remove index.php from URL

In Magento remove index.php from URL using below steps. It will convert your URL from


1.) In Magento Admin > System > Configuration > Web > Search Engine Optimization, change the value of Web Server Rewrites to Yes

Make sure your web server rewrite module is enabled. If you are using apache as your web server on Linux, you can check it by going to /etc/apache2/mods-enabled/rewrite.load, if rewrite.load is present there it means your rewrite module is enabled. If not, you will need to copy rewrite.load from /etc/apache2/mods-available/ and paste it at /etc/apache2/mods-enabled/ location. Then reload the apache by running service apache2 reload.

2.) Check the file permission of .htaccess, it should be present in Magento root directory and readable by server.

May 23, 2013

Magento clone collection – How to clone collection in Magento

Clone collection in Magento in an easy and effective way. Cloning collection in Magento is not as straight forward as we do in PHP object cloning. That’s because Magento does not implement clone in it’s collection object, which is why if you try to clone Magento collection it will nothing but just a copy of the original collection itself. If the original collection gets updated, this cloned will also get updated, which is what we don’t want right?

Let’s see an example where PHP’s clone keyword will fail. Consider you have an $collection in the class method and you want to perform operations on this $collection in two different ways. So you need to clone this $collection and perform operation differently in both the collections so that both collections have different result set.

$coll1 = clone $collection;
$coll2 = clone $collection;

Let’s perform different operations on these two separate collections now, like this:

$coll1->getSelect()->where('first where condition');
$coll2->getSelect()->where('second where condition');
if($coll1->getSize() == 0) {
    $collection = $coll2;
} else {
    $collection = $coll1;

But this will fail and not work what we expect here. $collection here will hold BOTH the where conditions, instead of any one depending on the result of IF condition.

To overcome this, in Magento, what you have to do is:
Continue reading »

May 22, 2013

Magento Recoverable Error Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website

Magento Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /var/www/xxx/app/code/core/Mage/Core/Model/App.php on line 634 and defined in /var/www/xxx/app/code/core/Mage/Core/Model/Store.php on line 395

When migrating Magento site from old server to new server, this error often occurs and appears in var/log/system.log. It prevents your Magento Admin to load JS and CSS files hence your admin panel becomes skinless.

The solution to get rid of this and load JS and CSS files is to run the following mysql commands in Mysql console or phpMyAdmin.

UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';

What the above mysql commands does is:
– Disables foreign key checks on tables so that you don’t get any foreign key errors while executing immediate update queries.
– Updates store, store_group and website tables with ID = 0, for admin user

Once the above set of queries are executed, don’t forget to clear cache to reflect your changes.

May 20, 2013

Magento Pinterest extension Auto Pin multiple product images Plugin

We all know that Pinterest is very popular and a great tool for marketing variety of products. It can give you huge traffic to your website resulting in incredible sales and revenue. It have almost all types of categories to hold your pinned images so that your product gets noticed to potential customers. It even has an option to specify the price of the product, which only gives you interested buyers to your website.

Magento Pinterest Auto Pin product images by Magentools

If you have hundreds/thousands of products in your store and want to pin it on Pinterest it becomes very difficult, as Pinterest don’t provide multiple pinning of images. One by one pinning images is a nightmare if you have lots of products. There is also no official Pinterest API which can allow you to auto-pin your images through some kind of API.
Continue reading »


Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!




Magento top 50 contributors

Magento top 50 contributors