Reindexing in Magento Programmatically Or via Command Line

Magento provides Index Management to reindex content such as Product Attributes, catalog URL Rewrites, Catalog Search Index etc from admin panel.
But sometimes we are unable to access the backend and the need for reindexing arises or Reindexing error comes when trying from backend.
Create a file in root of your magento with following code to update the indexes programmatically.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
< ?php
//Following 3 lines will load the magento admin environment.
require_once 'app/Mage.php';
$app = Mage::app('admin');
umask(0);
 
// to reindex the processes we require their ids
// for default magento there are 9 processes to reindex, numbered 1 to 9. 
$ids = array(1,2,3,4,5,6,7,8,9);
 
// Sometimes there are processes from our custom modules that also require reindexing
// We need to add those ids to our existing array of ids
// To know the id of process, just hover on each process in your
// admin panel-> System-> Index Management
// You will get a url : admin/process/some_id/......
// this id corresponds to the process
 
$ids = array(1,2,3,4,5,6,7,8,9,390,391,478);
foreach($ids as $id)
{
//load each process through its id
try
{
$process = Mage::getModel('index/process')->load($id);
$process->reindexAll();
echo "Indexing for Process ID # ".$id." Done<br />";
}
catch(Exception $e)
{
echo $e->getMessage();
}
}
?>

Thats all, the above code will reindex your magento content.

Or. . .

you can do it directly from command line :

– Index all indexers

php -f shell/indexer.php –reindex all

Note : your current directory should be magento root.

Installing phpMyAdmin+Magento on Ubuntu 11.04+ for Nginx Web Server

Before proceeding make sure you have a working LEMP installation following this tutorial .

Make sure you are logged with root privileges.

Installing phpMyAdmin

apt-get install phpmyadmin

-Press ‘Y’ on promt during installation

-Web Server to reconfigure automatically : select none (apache2 and lighttpd are ) -> Press Esc to select none

Vhost Configuration

mkdir -p /var/www/www.example.com/web

-p, no error if existing, make parent directories as needed

- replace www.example.com with your domain name or IP address.

Continue reading

How To Change Default Admin URL in Magento

Make sure you can access local.xml file present in app/etc/local.xml.

Open this file in edit mode and look for below piece of code at the end of the file-

<admin>
   <routers>
      <adminhtml>
          <args>
            <frontName><![CDATA[admin]]></frontName>
         </args>
     </adminhtml>
  </routers>
</admin>

change [admin] to anything you like. Save and close the file. Clear cache

Go to browser and type http://www.your_website.com/your_admin_path.