Category » Magento

Running Magento indexer from command line (shell)

Magento maintain various index tables to make data access faster. Magento core updates the indexes itself when you save a product but in some cases you may be required to update the indexes yourself. There are two ways to update the indexes from Magento admin or using the command line.

Continue reading »

Disabling the form submit on press of ENTER key

enter key

At times you would have seen that when you are filling a form on a website and you hit “ENTER” key the form gets submitted. As a developer you may have come across a situation where you would have wanted to prevent this action. The solution to this is to disable the “ENTER” key using javascript. Here’s a code snippet that disables “Enter” key in HTML textbox:

<script type="text/javascript">

// <![CDATA[
function disableEnterKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (elem.type=='text'))  {return false;}
}

document.onkeypress = disableEnterKey;
// ]]>

</script>

Continue reading »

Installing Magento with sample database

Magento

If you are going to use Magento for the first time then its good to install it with sample database to test it. Here are the steps to install it with sample database.

Step 1: Download Magento zip from  http://www.magentocommerce.com/download.

Step 2: Download sample data zip from http://www.magentocommerce.com/download.  It contains a sql file named magento_sample_data_for_1.6.1.0 and a media folder.

Step 3: Upload the Magento zip to your server and unzip it.

Step 4: Change the permissions of the following folders so that they are writable by the web server.

/app/etc
/var
/media

Using permission 755 will work, in case it does not work use the permission 777.

Step 5: Upload the Sample data zip to your server and unzip it.
 

Continue reading »

500 errors with Magento installation/upgrade

I was installing Magento, unzipped the files to a folder and accessed the URL but instead of getting the installation wizard I got 500 error. After much research I found that the issue was due to file permissions.

Continue reading »

Magento check if the current page is home page

The following code is used to check if the current page is homepage

<?php

if ( Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) :
?>

//Do something here

<?php

endif;

?>

Continue reading »

Magento check if the current page is a category page or not

We can use the following code to check if we are on a category page or not

<?php  if (Mage::registry('current_category')) : ?>
//Do something here
<?php  endif; ?>

Continue reading »

Back to top