public function listProductByCate($domain, $slug, $tagId, Request $request) { $productService = new productService(); $tagService = new tagService(); $userId = \Kacana\Util::isLoggedIn() ? $this->_user->id : 0; try { $tag = $request->input('tagId'); $page = $request->input('page', 1); $tag = $tag != "" ? $tag : $tagId; $sort = $request->input('sort'); $options = ['tagId' => $tag, 'sort' => $sort, 'product_tag_type_id' => TAG_RELATION_TYPE_MENU]; $limit = KACANA_PRODUCT_ITEM_PER_TAG; $data['items'] = $productService->getProductByTagId($tagId, $limit, $userId, $page, $options); $tags = $tagService->getTagById($tagId, false); $tags->allChilds = $tagService->getAllChildTagHaveProduct($tagId); $tagIdRelated = []; $tags->tagKeyword = $tagService->formatMetaKeyword($tags->allChilds, $tagIdRelated); $data['tag'] = $tags; $data['options'] = $options; } catch (\Exception $e) { if ($request->ajax()) { $result['error'] = $e->getMessage(); return $result; } else { return view('errors.404', ['error_message' => $e->getMessage()]); } } return view('client.product.listproduct', $data); }