コレクションでグループ句を使用するとグリッドのページネーションが機能しない
私は製品グリッドで作業していますが、ページ付けまたは製品数が機能していません(間違った数が表示されているため)。私のブロックの_preparecollection関数は次のとおりです。コレクションにカテゴリフィルターコードを追加したので、同じidが既に存在する場合のエラーを防ぐためにグループ句を使用する必要があります。 protected function _prepareCollection() { $store = $this->_getStore(); $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('sku') ->addAttributeToSelect('name') ->addAttributeToSelect('attribute_set_id') ->addAttributeToSelect('type_id') ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left'); $collection->addAttributeToFilter('category_id', array('in' => array(4,10))) ->distinct(true); $collection->getSelect()->group('e.entity_id'); if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { $collection->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'); } $collection->joinField('position', 'catalog/category_product', 'position', 'product_id=entity_id', null, 'left'); $collection->joinField('websites', 'catalog/product_website', 'website_id', 'product_id=entity_id', null, 'left'); if …