将产品添加到类别时,可以指定排序订单值。

现在成像,我们有一个类别“ P”设置为“锚”和各种类别“ C1”和“ C2”,它们是“ P”的孩子。

这些产品的定义顺序如何仅在子类别中,但在打开父类别时显示?

有帮助吗?

解决方案

看一眼 Mage_Catalog_Model_Resource_Category_Indexer_Product::_refreshAnchorRelations 特别是这些行:

$position = 'MIN('.
            $adapter->getCheckSql(
                'cp.category_id = ce.entity_id',
                'cp.position',
                '(cc.position + 1) * ('.$adapter->quoteIdentifier('cc.level').' + 1) * 10000 + cp.position'
            )
        .')';

ccce 是相同的 catalog_category_entity 桌子和 cpcatalog_category_product 桌子。

产品可以分为一个以上的儿童类别,因此产品位置是多个值之间的最小值。
因此,基本上,父类别中的产品位置是位置之间相对于每个类别中的最小值 catalog_category_product 遵循此公式:

(child category position + 1) * (child category level + 1) * 10000 + ( product position in catalog_category_product + 1)  

编辑
结论:在下面的产品中,将在树中较高位置的类别中的产品显示。

其他提示

正如Marius和Andreas的建议,您必须重写 Mage_Catalog_Model_Resource_Category_Indexer_Product 更改与 _refreshAnchorRelationsreindexAll.

为了 _refreshAnchorRelations

默认情况下

'(cc.position + 1) * ('.$adapter->quoteIdentifier('cc.level').' + 1) * 10000 + cp.position'

更改它

'cp.position + 10000'

为了 reindexAll

默认情况下

'('.$idxAdapter->quoteIdentifier('ce.position').' + 1) * '
.'('.$idxAdapter->quoteIdentifier('ce.level').' + 1 * 10000)'
.' + '.$idxAdapter->quoteIdentifier('cp.position')

更改它

'('.$idxAdapter->quoteIdentifier('cp.position').' + 10000)'

因此,它只会采用最低产品位置。我已经添加了 + 10000 因为我们的一些客户进入负面职位。

许可以下: CC-BY-SA归因
scroll top