为什么使用catalog_product_entity而不是catalog_product_flat_1数据库表的产品集合?

时间:2013-06-07 19:21:48

标签: magento

我有一个正在使用catalog_product_entity的magento安装,而其他人在查询期间使用catalog_product_flat_1来检索产品集合。

为什么会这样?

1 个答案:

答案 0 :(得分:3)

您可以配置Magento是否对集合使用平面表或实体。在Use Flat Catalog Product下的Magento管理部分中查看System->Config->Catalog: Frontend。更改此设置时会刷新Magento缓存存储,因为管理员配置已缓存。索引失效也可能在这里发挥作用,我不确定Magento是否在最新时使用平台。

Buttle Butkus报告可能需要将其切换为No并再次返回Yes以激活它。

如果要在管理区域中加载集合,则不使用平面表。

这是在Mage_Catalog_Model_Resource_Product_Collection::_construct()

中确定的
/**
 * Initialize resources
 *
 */
protected function _construct()
{
    if ($this->isEnabledFlat()) {
        $this->_init('catalog/product', 'catalog/product_flat');
    }
    else {
        $this->_init('catalog/product');
    }
    $this->_initTables();
}

/**
* Retrieve is flat enabled flag
* Return alvays false if magento run admin
*
* @return bool
*/
public function isEnabledFlat()
{
if (Mage::app()->getStore()->isAdmin()) {
    return false;
}
if (!isset($this->_flatEnabled[$this->getStoreId()])) {
    $this->_flatEnabled[$this->getStoreId()] = $this->getFlatHelper()
        ->isEnabled($this->getStoreId());
}
    return $this->_flatEnabled[$this->getStoreId()];
}