我想将目录产品列表中的产品分组。
我有4个可配置产品,我想将它们分组到目录中显示的1个产品。
为此,我创建了一个属性文本(assoccode)来关联每个可配置产品。
Config 1: code001 - assoccode: code001
Config 2: code002 - assoccode: code001
Config 3: code003 - assoccode: code001
Config 4: code004 - assoccode: code001
我的问题是,当我有一个没有其他选项的可配置产品时,它没有显示在目录列表中,或者是否是一个简单的产品,或者如果我将Anchor Category激活为是,我收到此错误: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'assoccode' in 'group statement'
是否有其他选项可以按目录产品列表中的属性对产品进行分组?
我将产品系列扩展如下:
class Module_GroupingConfig_Model_Productcollection extends Mage_Catalog_Model_Resource_Product_Collection
{
protected $_disabled = false;
protected $_flatEnabled = array();
public function getFlatHelper()
{
return Mage::helper('catalog/product_flat');
}
protected function isEnabled()
{
return !Mage::app()->getStore()->isAdmin() && !$this->_disabled;
}
public function setDisableGroupBy()
{
$this->_disabled = true;
}
public function isEnabledFlat()
{
// Flat Data can be used only on frontend
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
$storeId = $this->getStoreId();
if (!isset($this->_flatEnabled[$storeId])) {
$flatHelper = $this->getFlatHelper();
$this->_flatEnabled[$storeId] = $flatHelper->isAvailable() && $flatHelper->isBuilt($storeId);
}
return $this->_flatEnabled[$storeId];
}
protected function _beforeLoad()
{
if ($this->isEnabled()) {
if ($this->isEnabledFlat()) {
$this->getSelect()->group('assoccode');
$this->getSelect()->columns(array('assoccode_color_ids' => new Zend_Db_Expr("GROUP_CONCAT(DISTINCT color ORDER BY color_value DESC SEPARATOR ',')")));
} else {
$this->joinAttribute('assoccode', 'catalog_product/assoccode', 'entity_id');
$this->joinAttribute('color', 'catalog_product/color', 'entity_id');
$this->getSelect()->group('assoccode');
$this->getSelect()->columns(array('assoccode_color_ids' => new Zend_Db_Expr("GROUP_CONCAT(DISTINCT at_color.value ORDER BY at_color.value DESC SEPARATOR ',')")));
}
$this->getSelect()->columns(array('assoccode_count' => new Zend_Db_Expr('COUNT(*)')));
}
return parent::_beforeLoad();
}
public function getSelectCountSql()
{
if ($this->isEnabled()) {
$this->_renderFilters();
if ($this->isEnabledFlat()) {
$countSelect = $this->_getClearSelect()
->columns('COUNT(DISTINCT assoccode) AS cnt')
->resetJoinLeft();
} else {
$countSelect = $this->_getClearSelect()
->columns('COUNT(DISTINCT at_assoccode.value) AS cnt')
->resetJoinLeft();
}
$countSelect->reset(Zend_Db_Select::GROUP);
return $countSelect;
}
return parent::getSelectCountSql();
}
}
非常感谢任何帮助。
答案 0 :(得分:0)
1.您需要在admin,catalog - >中创建属性产品。属性 - >管理属性 之后,创建一个"设置属性" ,一旦成功,就与可配置产品相关联,
2.创建自定义模块块视图和列表,使用属性渲染组产品作为视图来选择
3.-进入明细产品视图使用自定义集合显示组产品和选项
4.创建自定义模块添加到购物车块,添加多个产品组