我有非EAV模型,该模型扩展了mage_core_model_resource_db_collection_abstract。

这是我的代码:

$this->getCollection()
        ->removeAllFieldsFromSelect()
        ->removeFieldFromSelect('credit_id')
        ->addFieldToSelect('product_id')
        ->addExpressionFieldToSelect('income', 'SUM({{income}})', 'income');

我需要按 * product_id *进行分组,但是所有父母课程都没有此功能。可以以某种方式分组吗?

有帮助吗?

解决方案

这应该有效:

$this->getCollection()->getSelect()->group('product_id')
许可以下: CC-BY-SA归因
scroll top