I have a custom module with its own table which saves the date inside the column named date_to.

I am trying to access the values from only this column but when I load the collection and call getData('date_to') I get the whole collection and not just the date_to column.

Here is what I have tried so far:

$date = Mage::getModel('namespace_modulename/tablename')->getData('date_to');


When I do print_r($date); I get the whole collection even though I have specified in parenthesis the I only want the date_to column values.

I know I'm missing out an important piece and would like for some help please.

  • try getDateTo() like Mage::getModel('namespace_modulename/tablename')->getDateTo() – Tim Hallman May 28 '15 at 17:08
  • @TimHallman thaks for your input, I get null returned when I use getDateTo() even though there are values in that colum... – user1704524 May 28 '15 at 17:17
  • @TimHallman yes, I get an error Call to undefined method Namespace_Module_Model_Resource_Custom_Data_Collection::getDateTo() – user1704524 May 28 '15 at 17:32
  • So when you do echo '<pre>';print_r($date);echo '</pre>'; do you see the date_to object or method? – Tim Hallman May 28 '15 at 17:38
  • @TimHallman Yes I get the object, namespace_modulename/tablename [_resourceModel:protected] => date_to [_resource:protected] – user1704524 May 28 '15 at 18:33

Thanks for the help, I had to loop over the collection like below:

$date = Mage::getModel('namespace_modulename/tablename');

$collection = $date->getCollection();
foreach($collection as $date_to){
  • can i write this code on controller file – Sarvesh Tiwari Jan 11 '17 at 12:34

Try doing

$date = Mage::getModel('namespace_modulename/tablename')->load($id);


where $id is the primary key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.