I'm having a curious problem in model's _construct function.
When the model is instantiated I would like to call a method to pull and save an access key from a database into a class property so it is immediately available, so I'm calling the method from within the _construct():
private $active_key
protected function _construct()
{
$this->_init('foo/foo');
$this->active_key = $this->getActiveKey();
}
The Method
public function getActiveKey()
{
return $this->getCollection()
->addFieldToSelect('foo_key')
->addFieldToFilter(
'foo_timestamp',
array('gt'=>$this->threshold)
)
->getFirstItem()
->getFooKey();
}
If I call getActiveKey() from a controller, all's fine and it returns the correct data. Using $this->getActiveKey() in the _construct, however, prompts a "No Data Received" error from our servers when instantiating the model class. Is there some sort of restriction against methods in the model _construct that I'm unaware of?
I know I could just chain the methods I require in the controller that will use the model, but I would like to understand why this is not working like I think it should.
Mage_Core_Model_Abstractor something else?