function viewAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT); if (!$id) { header('Location: /admin/notFound'); exit; } $productModel = new ProductTableModel(); $productModel->setId($id); $productModel->setTable('product'); $ImageModel = new ImageTableModel(); $ImageModel->setId($id); $ImageModel->setTable('image'); $images = $ImageModel->readRecordsById('product_id', '*', 'ORDER BY main'); $product = $productModel->readRecordsById()[0]; $categoryModel = new CategoryTableModel(); $product['category'] = $categoryModel->getCategoryById($product['category_id'])['category_name']; $product['subCategory'] = $categoryModel->getSubCategoryById($product['subcategory_id'])['subcategory_name']; if (!$product) { header('Location: /admin/notFound'); exit; } $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended'); $model->setData(['product' => $product, 'images' => $images, 'recommendedProducts' => Generator::recommendedProducts($recProducts)]); $output = $model->render('../views/product/product.php', 'withoutSlider'); $fc->setPage($output); }
function indexAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $popProducts = (new IndexWidgets())->recAndPopProductsWidget('popular', 6); $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended'); $model->setData(['slides' => IndexWidgets::getSliderWidget(), 'currentCategory' => (new IndexWidgets())->currentCategoryWidget(Helper::getSiteConfig()->currentCategoryWidget), 'popularProducts' => Generator::popularProducts($popProducts, 6), 'recommendedProducts' => Generator::recommendedProducts($recProducts)]); $output = $model->render('../views/index.php', 'main'); $fc->setPage($output); }