0

I have an shop that cannot reindex.

I've tried to re-index programmatically, with this code:

//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();
    }
}

But I still get an error. Here is the error:

An error occurred while saving the URL rewriteSQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`pukindustri`.`#sql-c67_7a9d2c9`, CONSTRAINT `FK_MAGE_MAGE_CAT_PRD_FLAT_1_ENTT_ID_MAGE_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `mage_catalog_product_entity` (`entity_id`) ON)Indexing for Process ID # 5 Done

Can someone help me to get the reindex to function again?

4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.