2014-02-25 16 views
1

的目的是什么是在Magento数据库_idx & _TMP表的目的。这些表中的数据如何更新?什么是cataloginventory_stock_status_idx&cataloginventory_stock_status_tmp的在Magento

我已经看到,cataloginventory_stock期间索引的Magento首先从表cataloginventory_stock_status &删除数据,然后最后通过运行查询

"INSERT INTO cataloginventory_stock_status SELECT * FROM cataloginventory_stock_status_idx"; 

嵌块的内部数据的数据在此表中,但我想了解的_idx &目的_tmp表,当&为什么Magento更新_idx & _tmp表中的数据。据我所知,这些不是主产品库存表。

+0

由于Magento的高度规范化,它有表格可以在* _idx表格中保存较少规范化的数据。当您从Magento Admin或通过shell indexer.php脚本运行索引过程时,_idx会更新。 –

+1

[cataloginventory \ _stock \ _status \ _idx表有什么意义?]的可能重复(http://stackoverflow.com/questions/10063434/whats-the-point-of-the-cataloginventory-stock-status-idx -表) – mniess

回答

2

我想知道同样的问题,并决定挖掘,因为我无法找到任何答案。 似乎_tmp和_idx被用作索引数据的临时持有者。

例如,你可以看看在app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.phpreindexAll()方法,你就会明白,它是利用_idx表来临时存储生成索引时,它的数据:

$this->useIdxTable(true); 
... 
$idxTable = $this->getIdxTable(); 
.... 
$query = $select->insertFromSelect($idxTable, ... 

在同样的方法结束你会注意到一个很好的$this->syncData()方法调用。你可能猜到了!该函数住在app/code/core/Mage/Index/Model/Resource/Abstract.php,并正是这样做的,同步的_idx与主:

$this->_getWriteAdapter()->delete($this->getMainTable()); 
$this->insertFromTable($this->getIdxTable(), $this->getMainTable(), false); 
$this->commit(); 

祝您好运!