public function action_edit($id = null) { if (empty($id) || !Model_Base_Product::valid_field('id', $id)) { Response::redirect('/admin/product'); } $this->data['category'] = Model_Base_Category::get_all(); $this->data['product'] = Model_Base_Product::get_one($id); $this->data['product']['category'] = Model_Base_ProductCategory::get_by('category_id', 'product_id', $id); $this->data['product']['sub_photo'] = Model_Base_Product::get_sub_photo($id); $this->template->content = View::forge($this->layout . '/product/edit', $this->data); }
public function action_detail($code = null) { $this->data['product'] = Model_Base_Product::get_by_code($code, array('where' => array(array('status', '=', 1)))); if (empty($this->data['product']['id'])) { Response::redirect('/'); } $this->data['product']['sub_photo'] = Model_Base_Product::get_sub_photo($this->data['product']['id']); $category_ids = Model_Base_ProductCategory::get_by('category_id', 'product_id', $this->data['product']['id']); if (!empty($category_ids)) { $this->data['products'] = Model_Base_Product::get_by_category_ids($category_ids, 0, 5); } View::set_global('product', $this->data['product']); $this->template->title = 'Product List'; $this->template->content = View::forge($this->layout . '/product/detail', $this->data); }