The magic getter and setter methods only apply to Magento objects that inherit from Varien_Object
. In practices that's Models, and Blocks. A collection is neither a model or a block. A collection is a foreach
able object that contains 0 - N model objects.
A collection's getData
method will return the raw PHP array of each model in the collection.
#File: lib/Varien/Data/Collection/Db.php
public function getData()
{
if ($this->_data === null) {
$this->_renderFilters()
->_renderOrders()
->_renderLimit();
$this->_data = $this->_fetchAll($this->_select);
$this->_afterLoadData();
}
return $this->_data;
}
What you probably want to do is grab the first model from the collection, and then grab its data.
$data = $collection->getFirstItem()->getData();
$field1 = $collection->getFirstItem()->getField1();