public function attributes($cids = "", $pid = "") { $ahc = new AttributeHelper(); $arrAtr = null; if ($pid != "") { $products = $this->productModel->fetchProductById($pid); $arrAtr = $ahc->getAttributesForProduct($products[0], $cids); } else { $arrAtr = $ahc->getAttributesForCategories($cids); } if ($arrAtr != null) { echo json_encode($arrAtr); } }