Skip to content

Commit c0ea9e4

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

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
@@ -500,6 +500,23 @@ public function getAllIds()
500500
$idsSelect->columns($this->getResource()->getIdFieldName(), 'main_table');
501501
return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
502502
}
503+
504+
/**
505+
* Retrieve field values for collection
506+
*
507+
* @return array
508+
*/
509+
public function getColumnValues($fieldName)
510+
{
511+
$idsSelect = clone $this->getSelect();
512+
$idsSelect->reset(\Magento\Framework\DB\Select::ORDER);
513+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
514+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
515+
$idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
516+
517+
$idsSelect->columns($fieldName, 'main_table');
518+
return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
519+
}
503520

504521
/**
505522
* Join table to collection select

0 commit comments

Comments
 (0)