public function searchArticleByCategory($key, $categoryId) { if ($categoryId == 0) { $this->mArticles = Product::SearchArticleByCategory($key); echo json_encode($this->mArticles); } else { $this->mArticles = Product::SearchCategoryArticleByCategory($key, $categoryId); echo json_encode($this->mArticles); } }