*/ class Mage_Api_Model_Resource_Rules_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract { /** * Resource collection initialization * */ protected function _construct() { $this->_init('api/rules'); } /** * Retrieve rules by role * * @param int $id * @return Mage_Api_Model_Resource_Rules_Collection */ public function getByRoles($id) { $this->getSelect()->where("role_id = ?", (int)$id); return $this; } /** * Add sort by length * * @return Mage_Api_Model_Resource_Rules_Collection */ public function addSortByLength() { $this->getSelect()->columns(array('length' => $this->getConnection()->getLengthSql('resource_id'))) ->order('length DESC'); return $this; } }