Skip to content

Commit daf5fb9

Browse files
author
Shikha Mishra
authored
Updated AbstractCollection.php
added getColumnValues function in collection for getting all values with reset limits
1 parent 4599646 commit daf5fb9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,23 @@ public function getAllIds()
492492
$idsSelect->columns($this->getResource()->getIdFieldName(), 'main_table');
493493
return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
494494
}
495+
496+
/**
497+
* Retrieve field values for collection
498+
*
499+
* @return array
500+
*/
501+
public function getColumnValues($fieldName)
502+
{
503+
$idsSelect = clone $this->getSelect();
504+
$idsSelect->reset(\Magento\Framework\DB\Select::ORDER);
505+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
506+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
507+
$idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
508+
509+
$idsSelect->columns($fieldName, 'main_table');
510+
return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
511+
}
495512

496513
/**
497514
* Join table to collection select

0 commit comments

Comments
 (0)