Blog

Magento: Common Issues and Resolutions

Tags: access deniedblogmagentoredirectionsef

Published on: October 16, 2014 by Irshad K.

Magento: Common Issues and Resolutions

Scenario:

This tutorial will show you solutions to some of the  Magento common issues that users face when managing their online shops. It covers the following topics on the top 10 Magento common issues :

1. Configure Magento to work with a new domain;

There are two things you should do in order to configure Magento to work with a new domain:

DataBase Modification 

Go to your cPanel > phpMyAdmin.

Select your Magento database from the  left menu, find the table called core_config_data and click on it.

Click the Browse tab and edit the first two fields:

web/unsecure/base_url
web/secure/base_url

by clicking the pen icon in front of each of them.

Replace your old domain name with your new domain name and click the Go button to save the change.

Clear the Magento cache.

If the site still resolves to the old domain name, it could be related with the Magento cache.

The Magento cache folder is located in your Magento  installation_directory/var/cache.

To clear the cache, simply delete the folder.

Many Magento issues can be fixed just by deleting the cache.

2. Reset  Magento admin password

To change your Magento admin password, go to your cPanel > phpMyAdmin -> Magento database, click the SQL tab and paste this query:

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

Note:

You have to change newpass in the MD5(‘sGnewpass‘) with your new password, and change *AdminUsername* to your Magento admin username.

Execute the query by clicking the Go button and your password will be changed.

3. Enable SEF (Search Engine Friendly)  URLs 

To enable Search Engine Friendly URLs in Magento, you have to log in to the Magento administration area and click on the Configuration button. Under the System navigation menu, switch to Web page from the sub-navigation panel on the left.

When the page loads, you will see blue lines which represent closed options tablets. Click on the Search Engines Optimization tab and turn on the Use Web Server Rewrites (mark as Yes). Click on the Save Config button and your Magento SEF URLs will be enabled.

4. Improve Speed 

Many Magento issues are caused by slow performance. The recommended way to speed up Magento’s performance is to enable its Compilation function.  The performance increase is between 25%-50% on page loads.

You can enable Magento Compilation from your Magento admin panel > System > Tools > Compilation.

 $ cd shell
$ php -f compiler.php help 

This assumes you have PHP available on the command line. If not, contact your system administrator.

You should see output something like the following

Usage: php -f compiler.php -- [options]
state Show Compilation State
compile Run Compilation Process
clear Disable Compiler include path and Remove compiled files
enable Enable Compiler include path
disable Disable Compiler include path
help This help

 This is a list of commands to use with the compiler.

Some of these commands assume you’re running from the shell folder, which is why we had you cd into shell first. Let’s try compiling our system. You’ll want to experiment on a non-production system, as errors during compilation can white screen your store. Type the following

 $ php compiler.php compile
Compilation successfully finished
$ 

This may take a few minutes, as Magento is traversing your system and pulling out every possible class.

If you take a look at the includes/src directory, you’ll see all your classes (over 5500 of them!)

 $ ls ../includes/src 

You can also get some stats on your compilation by typing

 $php compiler.php state
 Compiler Status: Enabled
 Compilation State: Compiled
 Collected Files Count: 5602
 Compiled Scopes Count: 4 

You probably noticed Compiler Status: Enabled.

This is one of the fussy things we mentioned. After compiling your classes, Magento immediately puts itself into “read from the compiled code” mode. You can turn this off by doing

 $php compiler.php disable
Compiler include path disabled 

Now let us check the outcome of the last command

 $ php compiler.php state
Compiler Status: Disabled
Compilation State: Compiled
Collected Files Count: 5602
Compiled Scopes Count: 4 

Your compiled classes will still be there, but now Magento is loading classes from its normal code pools. If you wanted to remove the compiled classes, running

 $php compiler.php clear
Compilation successfully cleared 

Now check the output and compare it with the previous result

 $ php compiler.php state
Compiler Status: Disabled
Compilation State: Not Compiled
 Collected Files Count: 0
Compiled Scopes Count: 0 

5. Magento redirection to www

For SEO and usability purposes you may want to redirect your visitors to open your site only through www (http://www.yourdomain.com). 

To do this in Magento, you should open the .htaccess file in the folder where your Magento is installed. In it locate the RewriteEngine on line and right after it add the following lines:

 RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC]
 RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] 

Once you do this, save the .htaccess file and log in to the Magento admin area > System > Configuration menu and from the left panel click the Web button.

Unfold the Unsecured set of options and change the Base URL option from http://yourdomain.com to http://www.yourdomain.com.

Save the changes and your Magento will start working through www.yourdomain.com only!

6. Disable the Compare products functionality

You can disable the Compare products functionality in Magento by following these steps:

Edit app/code/core/Mage/Catalog/Helper/Product/Compare.php and change the following code:

 public function getAddUrl($product)

{

return $this->_getUrl(’catalog/product_compare/add’, $this->_getUrlParams($product));

} 

 

To

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

Edit ./app/design/frontend/base/default/layout/catalog.xml (if you are using a different Magento theme, enter its name instead of default) and change the following code:

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

to

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

Flush the Magento cache from your Magento admin area > System > Cache Management.

7. Setting up a blog in Magento

It is not difficult to set up a blog in Magento. However, note that this functionality is not included by default and you will have to use a custom extension to add it.

You can search Magento Connect for an extension that will fully suit your needs. One of the popular free extensions that you can use is the Magento Blog – Community Edition.

All Magento extensions are installed in a similar way that is thoroughly explained in our Magento Connect Tutorial.

Once the extension is installed, you will have one additional section in the top menu of your Magento admin area called Blog. From there you can adjust the newly-installed Blog settings, add posts etc.

8. Add a “Contact Us” form in Magento

Magento includes contact form functionality by default. A link to a contact form can usually be found in the footer of your Magento installation.

Of course, you can add a contact form on any page. All you need to do is:

Log in to the administrator area.
Go to CMS > Pages.
Select the page you want to edit or create a new page.

Paste the following code using the HTML option of the WYSIWYG editor:

<!– CONTACT FORM CODE BEGIN–>
{{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}
<!– CONTACT FORM CODE END–>

Save the changes and the contact form will appear on the desired page.

9. “Access denied” issue

As a solution to the “Access denied” issue, you should log out from the Magento admin area and then log in again.

If the above does not help, you should reset the admin privileges. This can be done through the Magento admin area > System > Permissions > Roles > Administrators.

Click on the Role Resources option from the left menu and make sure that Resource Access is set to All.

Click on the Save Role button and the permissions will be reset.

10. Set a custom group of users

You can add a new group from the Magento admin area > Customers > Customer Groups > Add New Customer Group.

Once a customer registers, you can change the group he/she belongs to from the Magento admin area > Customers > Manage Customers. Click on the Edit link next to the customer and change the group from the Account Information > Customer Group. Click Save Customer.

Set the discount from Promotions > Catalog Price Rules > Add New Rule.

In the Customer Groups select the customers’ groups for which the promotion is valid. Enter the other details, set the rule actions and conditions.  Finally, click Save Rule.

11. Magento install error – Exception printing is disabled

Here is a known error which can occur when installing Magento:

There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: XXXXXXXXXXXXXXX

Here is the solution:

  1. Navigate to the “errors” folder.
  2. Change local.xml.sample to local.xml
  3. You should now see a new list of crazy errors all over the Magento page – this is okay.
  4. Open magento/lib/Zend/Cache/Backend/File.php and look for:
    protected $_options = array(
    ‘cache_dir’ => ‘null’,
  5. Change it to:
    protected $_options = array(
    ‘cache_dir’ => ‘tmp/’,
  6. Save it.
  7. Now the final step is to go create a tmp folder in the root Magento folder.
  8. That’s it.

 Get 24/7 expert server management

 

Category : magento, Troubleshooting

Irshad K.

Irshad K.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Get new updates

Categories

$0.000 items