header-how-to-fix-common-magento-issues

Good day to Amasty blog readers!

Our support team consists of four managers now, and every day they answer hundreds of questions not only about Amasty extensions, but also on Magento itself. We collected some of the most frequent questions and answered them; we do hope that this small knowledge base will help people that have just started working with Magento.

How to make Magento work on a new domain name

  1. Change database settings

Go to any tool that you use to access your database, go to core_config_data and change the first two fields (web/unsecure/base_url and web/secure/base_url) by replacing your old domain with the new one.

  1. Clear cache

Go to /var/cache and clear the folder.

How to change admin password in Magento

Go to PhpMyAdmin, choose Magento database, and paste this query to the SQL tab:

UPDATE admin_user SET password=CONCAT(MD5('sGnewpass'), ':sG') WHERE username='Admin';

Newpass and Admin must be changed by the new password and the admin user name accordingly. Click Go to apply the changes.

How to Create 301 Redirects for Magento

Go to Backend – Catalog – URL Rewrite Management. Click Add URL Rewrite button. Choose Custom from the Create URL Rewrite menu.

You’ll see the URL Rewrite Information form. Fill it in:

ID Path: enter the old URL. For instance, if you’re going to redirect site.com/page1.html, then enter page1.html in this field.

Request Path:  enter the old URL again.

Target Path: enter the new URL. Again, if the new URL will be site.com/page2.html, use page2.html only.

For Redirect choose Permanent (301).

You don’t have to fill the Description field in.

Save the changes, then go to your old page and check if the redirect is working as you want it to.

How to add a contact form in Magento

Magento has a contact form feature by default, and if it’s enabled, you’ll have a link to it in your footer. But what of you need to place your contact form on a particular page?

Make use of this code. Remember that you have to paste it using the HTML option when editing the CMS page.

<!– CONTACT FORM –>
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
<!– END OF CONTACT FORM –>

Or, you can use any Custom Form extension, such as the one from Amasty.

How to change Magento admin URL

Changing your admin URL is a matter of security. This method is more about security by obscurity, but can be useful as additional means of fighting against bots and brute force attacks. To change backend URL, edit app/etc/local.xml (admin / routers / adminhtml section).

<admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[your-secure-location]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
We do not recommend changing the default admin URL using the native interface of the Magento admin panel.

Make sure the new URL is quite hard to guess. You also might want to clear your cache after these steps.

Then check your new URL and make sure that the old URL returns 404 error page.

Get rid of .html in Magento URLs

Magento adds .html to category and product URLs by default. If you want to remove it, go to Backend – System – Config – Catalog – SEO tab, then delete .html from Product URL and Category URL suffixes.

Now, go to System – Index Management and reindex all data, plus clear your cache.

How to disable the product comparison feature in Magento

If you don’t want to use the product comparison feature, follow these steps:

1. Find and edit app/code/core/Mage/Catalog/Helper/Product/Compare.php file.

2. Find this piece of code:

public function getAddUrl($product)
{
return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product));
}

And replace it by:

public function getAddUrl($product)
{
//return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product)); return false;
}

3. Find and edit /app/design/frontend/base/default/layout/catalog.xml. Don’t forget to use your Magento theme name instead of the default one.
4. Find this piece of code:

<block type=”catalog/product_compare_sidebar” before=”cart_sidebar” name=”catalog.compare.sidebar” template=”catalog/product/compare/sidebar.phtml”/>

And replace it by:

<!– <block type=”catalog/product_compare_sidebar” before=”cart_sidebar” name=”catalog.compare.sidebar” template=”catalog/product/compare/sidebar.phtml”/> –>

5. Clear your cache.

500 Internal Server Error on Magento backend/frontend after turning compilation on

Go to Magento installation root and edit includes/config.php.

You’ll have one line uncommented and one commented out. Make it viсe versa: comment the first one out and uncomment the second one:

define('COMPILER_INCLUDE_PATH',

dirname(__FILE__).DIRECTORY_SEPARATOR.'src');

#define('COMPILER_COLLECT_PATH',

dirname(__FILE__).DIRECTORY_SEPARATOR.'stat');

That’s how it should be after your manipulations.

#define('COMPILER_INCLUDE_PATH',

dirname(__FILE__).DIRECTORY_SEPARATOR.'src');

define('COMPILER_COLLECT_PATH',

dirname(__FILE__).DIRECTORY_SEPARATOR.'stat');

503 Service Temporarily Unavailable error for no reason

If you have 503 message in your browser and can’t access fronted or backend, go to your Magento root installation, find a maintenance.flag file and delete it. Sometimes Magento just won’t come out of maintenance mode. If this doesn’t help, delete your cache and sessions and try again.

How to disable Magento admin notifications

Magento backend notifications can be pretty annoying, but you can turn them off really quick. Go to Backend – Configuration – Advanced – Advanced and disable Mage_AdminNotification.

Magento categories are not showing on the frontend

This is a very common question from those who have just installed Magento and are setting everything up. All categories must be placed inside the default category. To ensure this is correctly done click on the default category section at Backend – Manage Store, and then click Add subcategory. Make sure that Is Active and Is Anchor settings are enabled.

How to stop Magento from logging me out too soon

By default Magento has a very short cookie lifetime. To make that longer, go to Backend – Configuration – Web – Session Cookie Management – Cookie Lifetime.

Can’t access the Magento module administration page

If you have installed the module and can’t access the module administration page getting an error, clean your cache and relog at the backend. These simple actions will let Magento update permissions.

My Magento emails go to spam, and clients don’t receive them

Read our article on how to make sure your Magento emails don’t go to spam (plus there’s a free spam check tool available).

Google says there are thousands of your Magento store’s pages indexed

But you know you have a smaller number of them. Most probably your Magento store has generated lots of duplicate pages. Read how to get rid of them.

Shopping cart price rules not working

Here’s a common mistake people are making when creating rules for discounts attached to, say, a category:

How to fix common Magento issies - shopping cart price rules not working

After saving the rule users complain that it is applied no matter if conditions are observed.

The issue is hidden in ‘if total quantity greater than 0’. Basically, you shouldn’t compare anything with null, so you’d better use ‘If total quantity equals or greater than 1’, which works the same.

Also, there is a common issue when using list rules. For example, here’s a rule using several SKUs or categories:

How to fix common Magento issues - Shopping cart price rules

Here we use the presence of products with ‘750′, ‘iddqd’, or ‘sample-product’ SKUs in the shopping cart as a condition. But we’ve chosen ‘SKU is‘, so Magento will search for ‘750,iddqd,sample-product’ SKU, but there is obviously no such product, and the rule won’t be working as the condition is not observed.

In this case we should use ‘is one of’ instead of ‘is’. For example, ‘SKU is one of 750,iddqd,sample-product‘, and Magento will search for any of these SKUs in the shopping cart.

How to turn an extension off fast

This method works when you install an extension, and it turns out you get critical errors. Go to \app\etc\modules, where you’ll see XML files. To switch an extension off, rename its XML file, for example, you have Cool_extension.xml, rename it to Cool_extension.xml.off and clear your cache. If your errors appeared because of this extension, now they must be gone.

Note: there are files starting with Mage in the same folder; we don’t recommend turning them off unless you know for sure what you are doing, because these are Magento files.

How to activate several shopping cart rules with one coupon

By default Magento doesn’t allow activating several shopping cart rules by one coupon, but there’s a way to change it.

Use this database request:

DROP INDEX `UNQ_SALESRULE_COUPON_CODE` ON `salesrule_coupon`

Then open  /app/code/core/Mage/SalesRule/Model/Resource/Coupon.php, find lines 43-46 and comment them out like that:

/*$this->addUniqueField(array(
'field' => 'code',
'title' => Mage::helper('salesrule')->__('Coupon with the same code')
)); */

Do you have any questions on the issues listed above? We’d love to help!