Created
January 21, 2014 00:44
-
-
Save xcommerce-gists/8532268 to your computer and use it in GitHub Desktop.
Sample Magento collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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