Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
Created January 21, 2014 00:44
Show Gist options
  • Save xcommerce-gists/8532268 to your computer and use it in GitHub Desktop.
Save xcommerce-gists/8532268 to your computer and use it in GitHub Desktop.
Sample Magento collection
<?php
/**
* News collection
*
* @author Magento
*/
class Magentostudy_News_Model_Resource_News_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
/**
* Define collection model
*/
protected function _construct()
{
$this->_init('magentostudy_news/news');
}
/**
* Prepare for displaying in list
*
* @param integer $page
* @return Magentostudy_News_Model_Resource_News_Collection
*/
public function prepareForList($page)
{
$this->setPageSize(Mage::helper('magentostudy_news')->getNewsPerPage());
$this->setCurPage($page)->setOrder('published_at', Varien_Data_Collection::SORT_ORDER_DESC);
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment