<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB listing products by category.
*
* @package OSB
* @subpackage Product
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Category extends ORM_OSB {
protected $_table_name = 'product_cat';
protected $_has_many = array(
'product_category_translate'=>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=Config::instance()->so;
return ($a=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $a : _('No Description');
}
public function list_bylistgroup($cat) {
$result = array();
foreach ($this->where('list_group','=',$cat)->find_all() as $pco)
$result[$pco->id] = $pco;
return $result;
?>