There are different ways we can re-index magento data.
I have created three different examples on how to reindex data.
Example 1: reindex data via magento admin panel.
Easiest way is to login magento admin panel, got o “Systems > Index Management” and select all indexs, action to “Reindex Data” and click on submit button.
Example 2: how to reindex data programmatically in magento?.
Magento has different 9 different indexes. If you want to refresh all of them then following code will help you.
view plaincopy to clipboardprint?
for ($i = 0; $i < = 8; $i++) {
$process = Mage::getModel('index/process')->load($i);
$process->reindexAll();
}
Example 3: Out of the box data reindexing in magento?.
Create a file reindex.php and execute this file on linux command prompt. If you reindex data manually using following script it will resolve the problem like reindex is incomplete or still showing indexing from long time, etc.
PS: Change path for ‘Mage.php’ & “indexer.php” file path in following code according to environment.
view plaincopy to clipboardprint?
set_time_limit(0);
error_reporting(0);
require_once '/var/www/html/app/Mage.php';
umask(0);
$indexer="/var/www/html/shell/indexer.php";
if(file_exists($indexer))
{
$idxlist=array("catalog_product_attribute",
"catalog_product_price",
"catalog_product_flat",
"catalog_category_flat",
"catalog_category_product",
"catalog_url",
"catalogsearch_fulltext",
"cataloginventory_stock");
//reindex using magento command line
foreach($idxlist as $idx)
{
echo "reindex $idx n ";
exec("php /var/www/html/shell/indexer.php --reindex $idx");
}
}
I have created three different examples on how to reindex data.
Example 1: reindex data via magento admin panel.
Easiest way is to login magento admin panel, got o “Systems > Index Management” and select all indexs, action to “Reindex Data” and click on submit button.
Example 2: how to reindex data programmatically in magento?.
Magento has different 9 different indexes. If you want to refresh all of them then following code will help you.
view plaincopy to clipboardprint?
for ($i = 0; $i < = 8; $i++) {
$process = Mage::getModel('index/process')->load($i);
$process->reindexAll();
}
Example 3: Out of the box data reindexing in magento?.
Create a file reindex.php and execute this file on linux command prompt. If you reindex data manually using following script it will resolve the problem like reindex is incomplete or still showing indexing from long time, etc.
PS: Change path for ‘Mage.php’ & “indexer.php” file path in following code according to environment.
view plaincopy to clipboardprint?
set_time_limit(0);
error_reporting(0);
require_once '/var/www/html/app/Mage.php';
umask(0);
$indexer="/var/www/html/shell/indexer.php";
if(file_exists($indexer))
{
$idxlist=array("catalog_product_attribute",
"catalog_product_price",
"catalog_product_flat",
"catalog_category_flat",
"catalog_category_product",
"catalog_url",
"catalogsearch_fulltext",
"cataloginventory_stock");
//reindex using magento command line
foreach($idxlist as $idx)
{
echo "reindex $idx n ";
exec("php /var/www/html/shell/indexer.php --reindex $idx");
}
}
This comment has been removed by the author.
ReplyDeleteGreat Read! I am impressed on how you make your article easy to understand. I'll come back for more :D
ReplyDeleteJaps Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. For more tutorial and tips you can follow him here -> alwaysopencommerce.com