Reputation: 1328
How can I remove a field from a collection?
I found the method removeFieldFromSelect()
in Mage_Core_Model_Resource_Db_Collection_Abstract
, but it does not seems to work.
I tried:
$collection = Mage::getModel('bannermanagement/banner')->getCollection();
$collection->removeFieldFromSelect('status');
but still the field shows up. How can I remove the field Status from collection?
Upvotes: 0
Views: 2424
Reputation: 394
I checked that removeFieldFromSelect
is available in Magento, but it not used anywhere. However, you can achieve it like this:
Clone your Collection in your custom module Collection file
$idsSelect = clone $this->getSelect();
and then reset the Columns
$idsSelect->reset(Zend_Db_Select::COLUMNS);
and then set the columns again
$idsSelect->columns($this->getResource()->getIdFieldName(), 'main_table');
Upvotes: 2