Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Rebuild search index within code? 
 
jeff.meyer
Member
 
Total Posts:  51
Joined:  2008-11-24
 

How would I properly rebuild the search index via PHP?

I am doing quite a bit of dynamic importing of products and it seems necessary for proper search results after an inventory import/update.  Thank in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jeff.meyer
Member
 
Total Posts:  51
Joined:  2008-11-24
 

Can anyone guide me in the right direction to find where (within the code) the admin panel accesses this functionality?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Daim
Sr. Member
 
Total Posts:  172
Joined:  2008-01-08
Germany
 

Make a new file in the magento base dir. i call it cron2.php grin

require 'app/Mage.php';

#echo "start";
if (!Mage::isInstalled()) {
    
echo "Application is not installed yet, please complete install wizard first.";
    exit;
}

// Only for urls
// Don't remove this
$_SERVER['SCRIPT_NAME'str_replace(basename(__FILE__), 'index.php'$_SERVER['SCRIPT_NAME']);
$_SERVER['SCRIPT_FILENAME'str_replace(basename(__FILE__), 'index.php'$_SERVER['SCRIPT_FILENAME']);
Mage::app();
try 
{
        Mage
::getSingleton('catalogsearch/fulltext')->rebuildIndex();
        
#echo "ok";
    
}
catch (Mage_Core_Exception $e)
    
{
        
echo "fail  ".$e->getMessage();
    
}
catch (Exception $e)
{
        
echo "big fail";
}
?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
jeff.meyer
Member
 
Total Posts:  51
Joined:  2008-11-24
 
Daim - 30 June 2009 06:14 AM

Make a new file in the magento base dir. i call it cron2.php grin

Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex();

Awesome!  Thanks, that was exactly what I needed.  I appreciate your response!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Daim
Sr. Member
 
Total Posts:  172
Joined:  2008-01-08
Germany
 

no problem grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top