public function action_home() { $this->data['highlight_product'] = Model_Base_Product::get_by(array('where' => array(array('highlight', '=', 1), array('status', '=', 1)), 'limit' => 5)); $this->data['new_product'] = Model_Base_Product::get_by(array('where' => array(array('status', '=', 1)), 'limit' => 8)); $this->data['product_category'] = Model_Base_Category::get_all(array('where' => array(array('parent_category_id', '=', 0), array('status', '=', 1)))); foreach ($this->data['product_category'] as $key => $value) { $this->data['product_category'][$key]['product'] = Model_Base_Product::get_by_category($value['id'], 0, 4); } $this->template->title = 'Home Page'; $this->template->content = View::forge($this->layout . '/home/home', $this->data); }
public function post_list() { $page = (int) Input::post('page') !== 0 ? (int) Input::post('page') : 1; $code = Input::post('code'); $category_id = Model_Base_Category::get_id_by_code($code); $total = Model_Base_Product::count_by_category($category_id); $limit = _DEFAULT_LIMIT_; $offset = $page * $limit - $limit < $total ? $page * $limit - $limit : _DEFAULT_OFFSET_; $this->data['products'] = Model_Base_Product::get_by_category($category_id, $offset, $limit); $this->data['success'] = true; return $this->response($this->data); }