views:

28

answers:

0

In magento, after rebuilding programmatically the flat product catalog with the script I found at http://www.magentocommerce.com/boards/viewthread/43238/ I keep getting the error exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.display_price_group_0' in 'field list'' whenever I try to update a product's properties.

Even more strange, I checked on other installations of Magento and there seem to be no column "display_price_group_0" in the table catalog_product_flat_1...

Does anybody have a hint as to what is happening? What is the correct way to programmatically rebuild the flat catalog? Thank you a lot!

<?php 

// Carico l'enviroment dell'istallazione di Magento per sfruttare i suoi Model 
require_once('..'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Mage.php');
Mage::app();

// Inizializzo il file di log                  
$logFileName = 'clear_cache.log';
Mage::log("Inizio pulizia cache",null,$logFileName); 

try {
  Mage::getSingleton('catalog/url')->refreshRewrites();
  Mage::log("[INFO] Catalog rewrites e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getSingleton('catalog/index')->rebuild();
  Mage::log("Catalog Index e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf();
  if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING){
    $kill = Mage::getModel('catalogindex/catalog_index_kill_flag')->loadSelf();
    $kill->setFlagData($flag->getFlagData())->save();
  } 
  $flag->setState(Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED)->save();
  Mage::getSingleton('catalogindex/indexer')->plainReindex();
  Mage::log("[INFO] Layered Navigation Indices e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getModel('catalog/product_image')->clearCache();
  Mage::log("[INFO] Image cache e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex();
  Mage::log("[INFO] Search Index e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getSingleton('cataloginventory/stock_status')->rebuild();
  Mage::log("[INFO] CatalogInventory Stock Status e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getResourceModel('catalog/category_flat')->rebuild();
  Mage::log("[INFO] Flat Catalog Category e' stato aggiornato con successo",null,$logFileName);
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}
try {
  Mage::getResourceModel('catalog/product_flat_indexer')->rebuild();
  Mage::log("[INFO] Flat Catalog Product e' stato aggiornato con successo",null,$logFileName);  
} catch (Exception $e) {
  Mage::log("[ERRORE] " . $e,null,$logFileName);
}

Mage::log("Fine pulizia cache",null,$logFileName);  
?>