分层导航我们有一个分层的导航(screenshot),让我们的用户按类别,价格和颜色过滤。类别和价格工作得很好,因为它们默认为Magento。尝试按颜色(自定义属性)进行过滤时会出现问题。与自定义属性
它引发异常。我能够追踪堆栈轨迹,但我无法理解它。想知道是否有人能帮助我指出正确的方向。跟踪:https://gist.github.com/4490917
我们使用Magento企业v1.12.0.2
分层导航我们有一个分层的导航(screenshot),让我们的用户按类别,价格和颜色过滤。类别和价格工作得很好,因为它们默认为Magento。尝试按颜色(自定义属性)进行过滤时会出现问题。与自定义属性
它引发异常。我能够追踪堆栈轨迹,但我无法理解它。想知道是否有人能帮助我指出正确的方向。跟踪:https://gist.github.com/4490917
我们使用Magento企业v1.12.0.2
有与应用程序/法师/目录/型号/资源/层/过滤器的问题/ Attribute.php
交换以下列出你的课程,并解决它的问题。
class Mage_Catalog_Model_Resource_Layer_Filter_Attribute extends Mage_Core_Model_Resource_Db_Abstract
{
/**
* Initialize connection and define main table name
*
*/
protected function _construct()
{
$this->_init('catalog/product_index_eav', 'entity_id');
}
/**
* Apply attribute filter to product collection
*
* @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
* @param int $value
* @return Mage_Catalog_Model_Resource_Layer_Filter_Attribute
*/
public function applyFilterToCollection($filter, $value)
{
$filterSingleton = FilterSingleton::singleton();
if (!isset($filterSingleton->return)) {
$collection = $filter->getLayer()->getProductCollection();
$attribute = $filter->getAttributeModel();
$connection = $this->_getReadAdapter();
$tableAlias = $attribute->getAttributeCode() . '_idx';
$conditions = array(
"{$tableAlias}.entity_id = e.entity_id",
$connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
$connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()),
$connection->quoteInto("{$tableAlias}.value = ?", $value)
);
$collection->getSelect()->join(
array($tableAlias => $this->getMainTable()),
join(' AND ', $conditions),
array()
);
$filterSingleton->return = $this;
return $this;
} else {
return $filterSingleton->return;
}
}
/**
* Retrieve array with products counts per attribute option
*
* @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
* @return array
*/
public function getCount($filter)
{
// clone select from collection with filters
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
// reset columns, order and limitation conditions
$select->reset(Zend_Db_Select::COLUMNS);
$select->reset(Zend_Db_Select::ORDER);
$select->reset(Zend_Db_Select::LIMIT_COUNT);
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
$connection = $this->_getReadAdapter();
$attribute = $filter->getAttributeModel();
$tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
$conditions = array(
"{$tableAlias}.entity_id = e.entity_id",
$connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
$connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()),
);
$select
->join(
array($tableAlias => $this->getMainTable()),
join(' AND ', $conditions),
array('value', 'count' => new Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")))
->group("{$tableAlias}.value");
return $connection->fetchPairs($select);
}
}
class FilterSingleton {
static private $instance;
public $return = null;
private function __construct() {
}
static public function singleton() {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
}
http://aceph.tumblr.com/post/21851233473/magento-you-cannot-define-a-correlation-name
你可以简单地从布局下面的例子catalogsearch.xml删除enterprisesearch块:
<catalogsearch_result_index translate="label">
...
<reference name="left">
<remove name="enterprisesearch.leftnav"/>
</reference>
<reference name="right">
<block type="catalogsearch/layer" name="catalogsearch.rightnav" before="-" template="catalog/layer/view.phtml"/>
</reference>
...
</catalogsearch_result_index>
的错误发生,因为他们是两个块做同样的事情在布局。企业搜索在默认情况下存在。
你很快就能描述你改变了什么,为什么? –