function action_filter() { $beginPrice = $_POST['beginPrice']; $endPrice = $_POST['endPrice']; if ($beginPrice == "") { $beginPrice = 0; } if ($endPrice == "") { $endPrice = 0; } $c = $_POST['c']; if ($beginPrice <= $endPrice) { if ($c != "") { $productsVM = ProductHelper::PopulateProductViewModelList(ProductService::GetByCatalogue($c)); } else { $productsVM = ProductHelper::PopulateProductViewModelList(ProductService::GetAll()); } $k = 0; for ($i = 0; $i < count($productsVM); $i++) { if ($productsVM[$i]->price > $beginPrice && $productsVM[$i]->price < $endPrice) { $model[$k] = $productsVM[$i]; $k++; } } $this->view->generate('/Product/item_view.php', 'template_view.php', $model); } else { header("Location: /Product/index?c=" . $c); } }
public static function PopulateCatalogueViewModel($catalogue) { $model = new CatalogViewModel(); $model->id = $catalogue->catalogue_id; $model->name = $catalogue->name; $model->section = $catalogue->section->section_name; $model->products = ProductService::GetByCatalogue($model->name); return $model; }