Archive for November 2019

Database join with group

$limit = 1000; $d_collection = Mage::getResourceModel(’modulename/tablename_collection’) ->addFieldToFilter(’main_table_field’, true) ->setOrder(’entity_id’, ‘asc’) ->setPageSize($limit);   $d_collection->getSelect()->join( array(’tablename’=> Mage::getSingleton(’core/resource’)->getTableName(’modulename/tablename’)), ‘tablename.entity_id = main_table.entity_id’, array()); $d_collection->addFieldToFilter(’tablename.table_field’, 0); $d_collection->getSelect()->group(’main_table.entity_id’); $d_collection->addFieldToSelect(’entity_id’);