public function action_index($category_slug = '') { if ($category_slug != '') { $category = ProductCategory::bll()->findOneBy('slug', $category_slug); if (!$category) { //category not found } $this->template->title = __($category['name'] . " | Sản phẩm |"); $total_items = ProductItem::bll()->getItemsCountByCat_Front_Listing($category['id']); $pagging = Pagination::factory(array('total_items' => $total_items, 'items_per_page' => 12)); $items = ProductItem::bll()->getItemsByCat_Front_Listing($category['id'], $pagging->offset, $pagging->items_per_page); } $data['category'] = $category; $data['items'] = $items; $data['page_link'] = $pagging->render(); $this->template->content = View::factory('/front/product/item/list', $data); }
public function action_delete($product_id = 0) { $this->auto_render = false; $ok = false; $cat_id = 0; if (intval($product_id) > 0) { $item = ProductItem::bll()->find($product_id); if ($item) { $cat_id = $item->cat_id; $item->delete(); $ok = true; } } if ($ok) { Message::success('Xóa sản phẩm thành công!'); } else { Message::error('Xóa sản phẩm không thành công!'); } if ($cat_id != 0) { Request::instance()->redirect('/admin/product/by_cat/' . $cat_id); } else { Request::instance()->redirect('/admin/productcategory/index'); } }