public function indexAction() { $categories = new \modules\commerce\models\Commerce_categories(); $products = new \modules\commerce\models\Commerce_products(); $categories->_select = "commerce_category_id, parent, title"; $categories->parent = 0; $categories->featrued = 'yes'; $recent_products = $this->Database->query("SELECT commerce_products.*,`commerce_categories`.`title` " . "FROM `commerce_products` " . "JOIN `commerce_categories` ON `commerce_categories`.`commerce_category_id`=`commerce_products`.`commerce_category_id` " . "ORDER BY commerce_products.commerce_product_id DESC LIMIT 20")->result(); $offers = new \modules\commerce\models\Commerce_products_offers(); $offers->_select = "commerce_products_offer_id, title, commerce_product_id, offer_image"; return $this->render('commerce_home', ['categories' => $categories->get(), 'category_model' => $categories, 'offers' => $offers->get(), 'product_model' => $products, 'recent_products' => $recent_products]); }
public function manageAction($id = false) { $this->auth = true; $this->permission('manage'); if ($id) { $commerce = new \modules\commerce\models\Commerce_products_offers('edit'); } else { $commerce = new \modules\commerce\models\Commerce_products_offers('add'); } $commerce->attributes = $this->Input->input['post']; $products = Form_helper::queryToDropdown('commerce_products', 'commerce_product_id', 'name'); if ($id) { $commerce->commerce_products_offer_id = $id; } $commerce->language_id = $this->language->getDefaultLanguage(); if ($commerce->save()) { Uri_helper::redirect("management/commerce_products_offers"); } else { return $this->render('commerce_products_offers/manage', ['item' => $id ? $commerce->get() : null, 'products' => $products]); } }