我在一个站点(www.theprinterdepo.com)上遇到了一个非常奇怪的问题,在谷歌浏览器中我看到了 500 个内部服务器错误。但是在 IE 和 firefox 上它可以正常工作)。我注意到的是,如果我转到 chrome 并单击历史记录并删除所有缓存、cookie 等,那么它会再次正常工作。
我删除了 system.log 并再次检查,唯一记录的是这个:
第一个参数应该是 /xxx/xxx/public_html/app/code/local/Mf/Searchterms/Model/Layer.php 中的一个数组
这是我从未接触过的标准 magento 文件,但这里是代码:
<?php
class Mf_Searchterms_Model_Layer extends Mage_Catalog_Model_Layer
{
const XML_PATH_DISPLAY_LAYER_COUNT = 'catalog/search/use_layered_navigation_count';
/**
* Get current layer product collection
*
* @return Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection
*/
public function getProductCollection()
{
if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
$collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
} else {
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
$this->prepareProductCollection($collection);
$this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
}
return $collection;
}
/**
* Prepare product collection
*
* @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection $collection
* @return Mage_Catalog_Model_Layer
*/
public function prepareProductCollection($collection)
{
$params = Mage::app()->getRequest()->getParams();
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
$query = Mage::helper('catalogsearch')->getQuery();
$productIds = Mage::getModel('searchterms/searchterms')->getProducts($query->getId());
$productIds = array_filter($productIds);
//var_dump($productIds);
if(is_array($productIds) && sizeof($productIds) > 0){
//echo "asd";
$productIdArray = $productIds;
$collection->addFieldToFilter('entity_id', array('in'=>$productIdArray));
$collection->joinField('position',
'searchterms_product',
'position',
'product_id=entity_id',
'searchterms_id='.$query->getId(),
'left')
;
if(isset($params['order']) && $params['order'] != ""){
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
}else{
$collection->setOrder(`searchterms_product`.'position','ASC');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
}
}
else
{
$collection->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText());
$collection->setStore(Mage::app()->getStore())
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addStoreFilter()
->addUrlRewrite();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
}
return $this;
}
/**
* Get layer state key
*
* @return string
*/
public function getStateKey()
{
if ($this->_stateKey === null) {
$this->_stateKey = 'Q_' . Mage::helper('catalogsearch')->getQuery()->getId()
. '_'. parent::getStateKey();
}
return $this->_stateKey;
}
/**
* Get default tags for current layer state
*
* @param array $additionalTags
* @return array
*/
public function getStateTags(array $additionalTags = array())
{
$additionalTags = parent::getStateTags($additionalTags);
$additionalTags[] = Mage_CatalogSearch_Model_Query::CACHE_TAG;
return $additionalTags;
}
/**
* Add filters to attribute collection
*
* @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Attribute_Collection $collection
* @return Mage_Catalog_Model_Resource_Eav_Resource_Product_Attribute_Collection
*/
protected function _prepareAttributeCollection($collection)
{
$collection->addIsFilterableInSearchFilter()
->addVisibleFilter();
return $collection;
}
/**
* Prepare attribute for use in layered navigation
*
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @return Mage_Eav_Model_Entity_Attribute
*/
protected function _prepareAttribute($attribute)
{
$attribute = parent::_prepareAttribute($attribute);
$attribute->setIsFilterable(Mage_Catalog_Model_Layer_Filter_Attribute::OPTIONS_ONLY_WITH_RESULTS);
return $attribute;
}
}
更新1: 我设法清理了apache错误日志,刷新了浏览器,然后这是日志上的新文本:[client 83.134.115.127]脚本头过早结束:index.php