Magento - 空白屏幕搜索结果。很多事情都破了

问题描述 投票:1回答:2

每当用户搜索时,我都会收到此错误:

2012-06-26 11:05:21.671 [NOTICE] [208.69.120.120:48175-0#hostname] [STDERR] PHP Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::getEntityTablePrefix() in /chroot/home/SITENAME/DOMAIN.COM/html/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php on line 505

而不是用户的结果出现,他们得到一个空白的白页 - 他们的结束没有错误,没有UI,只有白色。这是我注意到的第一个问题,但是在同一天开始出现以下问题:

  1. 白搜索结果
  2. 分层导航中所有子类别的子类别产品计数显示为0。
  3. 某些客户在登录时无法从其前端UI查看订单。
  4. 我们的订单导出脚本返回空白字段(1.7mb而不是4.3)。
  5. 我们的“美国制造”和“畅销书”页面正在回归更多的产品。

现在,我知道这些都是不正确的,因为如果我重新索引整个网站,在处理索引的一段时间内,所有上述工作。但是,当索引完成时,它会再次中断。在发生这一天的同一天,我们出现了一个错误页面,其中一个表已经破坏并应该修复。我们在所有表上运行了PHPMyAdmin的修复和优化功能,并修复了该错误 - 但所有这些仍然被破坏。

有什么想法吗?有什么想法可以尝试解决这个问题?我无法在任何地方发现这个错误 - 而Nexcess的那些人也无法为此找到任何东西。

感谢您的时间。

php mysql database magento
2个回答
4
投票

根据上面的评论,Magento告诉你它正试图在一个类没有定义该方法的对象上调用方法getEntityTablePrefix。特别是在这种方法中

#File: app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
public function getBackendTable()
{
    if ($this->_dataTable === null) {
        if ($this->isStatic()) {
            $this->_dataTable = $this->getEntityType()->getValueTablePrefix();
        } else {
            $backendTable = trim($this->_getData('backend_table'));
            if (empty($backendTable)) {
                $entityTable  = array($this->getEntity()->getEntityTablePrefix(), $this->getBackendType());
                $backendTable = $this->getResource()->getTable($entityTable);
            }
            $this->_dataTable = $backendTable;
        }
    }
    return $this->_dataTable;
}

鉴于这发生在下面的课程中

Mage_Catalog_Model_Resource_Product_Flat

它告诉我你已完成扩展和/或定制,假设你没有使用平面目录数据表,并且没有编码以使用平面表。

在这样的调试调用中删除

if(!is_callable(array($this->getEntity()),'getEntityTablePrefix'))
{
    mageDebugBacktrace();
    //debug_print_backtrace();
    exit;
}

在违规调用之前(当然在本地代码池覆盖中),将打印出一个应该指向违规代码的调用堆栈。


0
投票

似乎Mage_CatalogSearch_Model_Resource_Search_Collection::_getSearchEntityIdsSql的问题与使用产品扁平指数不兼容。

你可以重写类Mage_CatalogSearch_Model_Resource_Search_Collection并做两个小修改。

1)将新函数_getSearchEntityIdsSqlUsingFlatIndex添加到重写类。这个新功能(我希望)与原始_getSearchEntityIdsSql完全相同,但使用产品平面索引。

2)修改函数_getSearchEntityIdsSql,以便在启用和构建目录产品平面索引时调用新的_getSearchEntityIdsSqlUsingFlatIndex

看源代码:

    class VENDOR_MODULE_Model_PATHTOREWRITECLASS extends Mage_CatalogSearch_Model_Resource_Search_Collection {
    /**
     *  Retrieve SQL for search entities using product flat index.
     *
     * @param $query
     * @return Varien_Db_Select
     */
    protected function _getSearchEntityIdsSqlUsingFlatIndex($query)
    {
        /* @var $coreHelper Mage_Core_Model_Resource_Helper_Abstract */
        $coreHelper = Mage::getResourceHelper('core');
        $likeOptions = array('position' => 'any');

        $flatTableName = $this->getTable('catalog/product_flat').'_'.$this->getStoreId();

        /** @var Varien_Db_Select $select */
        $select = $this->getConnection()
            ->select()
            ->from($flatTableName, array('entity_id'));

        foreach ($this->_getAttributesCollection() as $attribute) {
            /** @var Mage_Catalog_Model_Entity_Attribute $attribute */

            if ($this->_isAttributeTextAndSearchable($attribute)) {

                $attributeCode = $attribute->getAttributeCode();

                $dbFieldName = in_array($attribute->getFrontendInput(), array('select', 'multiselect'))
                    ? $attributeCode.'_value'
                    : $attributeCode;

                if ($this->getConnection()->tableColumnExists($flatTableName, $dbFieldName)) {
                    $select->where($coreHelper->getCILike($dbFieldName, $this->_searchQuery, $likeOptions));
                } else {
                    Mage::log(__METHOD__.": Attribute '$attributeCode' is missing in flat index.", Zend_Log::NOTICE);
                }
            }
        }

        return $select;
    }

    /**
     * Retrieve SQL for search entities
     *
     * @param unknown_type $query
     * @return string
     */
    protected function _getSearchEntityIdsSql($query)
    {
        // HACK - make compatibility with flat index
        /** @var Mage_Catalog_Helper_Product_Flat $flatHelper */
        $flatHelper = Mage::helper('catalog/product_flat');
        if ($this->getStoreId() > 0
            && $flatHelper->isEnabled($this->getStoreId())
            && $flatHelper->isBuilt($this->getStoreId())
        ) {
            return $this->_getSearchEntityIdsSqlUsingFlatIndex($query);
        }
        // END HACK

        return parent::_getSearchEntityIdsSql($query);
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.