Update product category view to include default price_display configured by category

This commit is contained in:
Deon George
2013-01-11 13:33:57 +11:00
parent f08215717c
commit 3fa1ca3665
6 changed files with 88 additions and 53 deletions

View File

@@ -39,7 +39,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
*/
public function action_list() {
if ($this->request->param('id'))
$prods = ORM::factory('Product')->list_category($this->request->param('id'),FALSE);
$prods = ORM::factory('Product_Category',$this->request->param('id'))->products();
else
$prods = ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();

View File

@@ -36,30 +36,33 @@ class Controller_Product extends Controller_TemplateDefault {
* @todo Obey sort order
*/
public function action_category() {
$id = $this->request->param('id');
$output = '';
$cat = ORM::factory('Product_Category',$id);
$pco = ORM::factory('Product_Category',$this->request->param('id'));
if (! $cat->loaded())
if (! $pco->loaded())
HTTP::redirect('welcome/index');
BreadCrumb::name($this->request->uri(),$cat->name);
if (! $pco->status AND ! Kohana::$config->load('debug')->show_inactive)
HTTP::redirect('welcome/index');
BreadCrumb::name($this->request->uri(),$pco->name);
BreadCrumb::url('product','product/categorys');
BreadCrumb::url('product/category','product/categorys');
Block::add(array(
'title'=>sprintf('%s: %s',_('Category'),$cat->name),
'body'=>View::factory($this->viewpath().'/view')
->set('results',$this->_get_category($cat->id))
->set('cat',$cat->id),
));
}
foreach ($pco->products() as $po)
$output .= View::factory($this->viewpath().'/list_item')
->set('co',$pco)
->set('o',$po);
/**
* Obtain a list of pages in a category
*/
private function _get_category($id) {
return ORM::factory('Product')->list_category($id);
// If our output is blank, then there are no products
if (! $output)
$output = _('Sorry, no pages were found in this category, or your account is not authorized for this category.');
Block::add(array(
'title'=>sprintf('%s: %s',_('Category'),$pco->name),
'body'=>$output,
));
}
/**
@@ -81,7 +84,7 @@ class Controller_Product extends Controller_TemplateDefault {
$co = ORM::factory('Product_Category',$_GET['cid']);
// If the product category doesnt exist, or doesnt match the product
if (! $co->loaded() OR ! in_array($co->id,unserialize($po->avail_category)))
if (! $co->loaded() OR ! in_array($co->id,$po->avail_category))
HTTP::redirect('Product_Category/index');
BreadCrumb::name('product/view',$co->name);