collection->addFieldToSelect('col_name')
will include the ID column in result. To return only columns of interest, use
$collection->getSelect()
->reset(Zend_Db_Select::COLUMNS)
->columns(['col_name']);
Example:
$collection->getSelect()
->reset(Zend_Db_Select::COLUMNS)
->columns(['entity_id' => 'mageproductid', 'value' => 'userid']);
$result = $collection->toArray();
$result
output:
array(2) {
["totalRecords"] => int(1565)
["items"] => array(1565) {
[0] => array(2) {
["entity_id"] => string(2) "16"
["value"] => string(2) "24"
}
[1] => array(2) {
["entity_id"] => string(2) "17"
["value"] => string(2) "24"
}
[2] => array(2) {
["entity_id"] => string(2) "18"
["value"] => string(2) "24"
}
//...
Posted by kiatng to OpenMage (2018-11-16 01:43)