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 deleteAction($id = false)
 {
     $this->permission('delete');
     if (!$id) {
         return Brightery::error404();
     }
     $commerce = new \modules\commerce\models\Commerce_products_offers();
     $commerce->commerce_products_offer_id = $id;
     if ($commerce->delete()) {
         Uri_helper::redirect("management/commerce_products_offers");
     }
 }