array('foreign_key'=>'product_cat_id','far_key'=>'id'), ); protected $_sorting = array( 'name'=>'asc', ); public function description() { // If the user is not logged in, show the site default language // @todo This needs to change to the session language. if (! $ao=Auth::instance()->get_user()) $ao=Company::instance()->so(); return ($x=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $x : _('No Description'); } /** * List all the products belonging to this cateogry * @todo Consider if we should cache this */ public function products() { $result = array(); foreach (ORM::factory('Product')->where_active()->find_all() as $po) if (in_array($this->id,$po->categories())) array_push($result,$po); return $result; } public function list_bylistgroup($cat) { $result = array(); foreach ($this->where('list_group','=',$cat)->find_all() as $pco) $result[$pco->id] = $pco; return $result; } } ?>