public function indexAction()
 {
     $orderBy = array("1" => "price asc", "2" => "price desc", "3" => "discount asc", "4" => "discount desc");
     $numberPage = 1;
     $query = Products::query();
     //            -> where("is_available=1");
     if ($this->request->isPost()) {
         // SEARCH
         $name = $this->request->getPost("name");
         $status = $this->request->getPost("status");
         $category = $this->request->getPost("category");
         $subcat = $this->request->getPost("subcat");
         $order = $this->request->getPost("order");
         if ($name != "") {
             $query->andWhere("name like '%{$name}%'");
         }
         if ($category != "") {
             $query->andWhere("category_id={$category}");
         }
         if ($subcat != "") {
             $query->andWhere("sub_category_id={$subcat}");
         }
         if ($order != "") {
             $query->order($orderBy[$order]);
         }
     }
     if (!$status || $status == "") {
         $status = 'New';
     }
     if ($status != "All") {
         $query->andWhere("status='{$status}'");
     }
     $numberPage = $this->request->getQuery("page", "int");
     $productList = $query->execute();
     $products = new Paginator(array("data" => $productList, "limit" => 10, "page" => $numberPage));
     $categories = Categories::find();
     $statusTypies = ["New", "Confirmed", "Enabled", "Disabled", "Approved"];
     $postData = $this->request->getPost();
     $subcats = SubCategories::find();
     $this->view->page = $products->getPaginate();
     $this->view->categories = $categories;
     $this->view->subcats = $subcats;
     $this->view->statusTypies = $statusTypies;
     $this->view->postData = $postData;
     $this->view->orderBy = $orderBy;
     $this->view->status = $status;
     $this->view->categoriesJson = json_encode(Categories::find()->toArray());
     $this->view->subCatsJson = json_encode($subcats->toArray());
 }
 /**
  * Index action
  */
 public function indexAction()
 {
     $list = SubCategories::find();
     //$cat = Categories::findFirst();
     $sql = "SELECT sc.*, c.name as category_name FROM SubCategories sc JOIN Categories c ON c.id = sc.category_id";
     $query = $this->modelsManager->createQuery($sql);
     $list = $query->execute();
     //        $json_list = array();
     //
     //        foreach($list as $item) {
     //            $obj = array();
     //            $obj["name"] = $item->sc->name;
     //            $obj["id"] = $item->sc->id;
     //            $obj["category_name"] = $item->category_name;
     //
     //            array_push($json_list,$obj);
     //        }
     $this->view->list = $list;
     $this->view->json_list = json_encode($list->toArray());
 }