public function indexAction($id)
 {
     $products = new \modules\commerce\models\Commerce_products();
     $category = new \modules\commerce\models\Commerce_categories();
     $category->commerce_category_id = $id;
     $products->commerce_category_id = $id;
     return $this->render('commerce_category', ['item' => $category->get(), 'products' => $products->get(), 'product_model' => $products]);
 }
 public function indexAction($id)
 {
     $products = new \modules\commerce\models\Commerce_products();
     $categories = new \modules\commerce\models\Commerce_categories();
     $product_imgs = new \modules\commerce\models\Commerce_product_images();
     $product_imgs->commerce_product_id = $id;
     $info = $this->Database->query("SELECT commerce_products.*,`commerce_categories`.`title`,`commerce_categories`.`description` as category_desc, `commerce_brands`.`name` as brand, `commerce_brands`.`image` as brand_iamge " . "FROM `commerce_products` " . "JOIN `commerce_categories` ON `commerce_categories`.`commerce_category_id`=`commerce_products`.`commerce_category_id`" . "LEFT JOIN `commerce_brands` ON `commerce_brands`.`commerce_brand_id`=`commerce_products`.`commerce_brand_id`" . "WHERE commerce_products.commerce_product_id='{$id}'")->row();
     $main_category = $categories->getMainCategory($info->commerce_category_id);
     $related_products = $this->Database->query("SELECT commerce_products.*,`commerce_categories`.`title`,`commerce_categories`.`description` as category_desc " . "FROM `commerce_products` " . "JOIN `commerce_categories` ON `commerce_categories`.`commerce_category_id`=`commerce_products`.`commerce_category_id` " . "WHERE commerce_products.commerce_product_id != '{$id}' " . "AND commerce_categories.commerce_category_id = '" . $info->commerce_category_id . "' " . "ORDER BY rand() LIMIT 3")->result();
     return $this->render('commerce_product', ['item' => $info, 'categories' => $categories->get(), 'imgs' => $product_imgs->get(), 'product' => $products, 'main_cat' => $main_category, 'category_model' => $categories, 'product_model' => $products, 'related_products' => $related_products]);
 }
 public function deleteAction($id = false)
 {
     $this->permission('delete');
     if (!$id) {
         return Brightery::error404();
     }
     $commerce = new \modules\commerce\models\Commerce_categories();
     $commerce->commerce_category_id = $id;
     if ($commerce->delete()) {
         Uri_helper::redirect("management/commerce_categories");
     }
 }
 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 indexAction($offset = 0)
 {
     $category = new \modules\commerce\models\Commerce_categories();
     $brands = new \modules\commerce\models\Commerce_brands();
     $product = new \modules\commerce\models\Commerce_products();
     $category->_select = "commerce_category_id, title, parent";
     $category->parent = 0;
     $sorting = ['' => 'Sort By', 'name' => 'Name', 'low_price' => 'Low Price', 'heigh_price' => 'Heigh Price'];
     if (is_array($this->input->get('category_id')) && count($this->input->get('category_id')) && !empty($this->input->get('category_id.0'))) {
         $product->where('commerce_category_id IN (SELECT commerce_category_id FROM commerce_categories WHERE parent IN ("' . implode('","', $this->input->get('category_id')) . '")) ');
     }
     //UNION ALL SELECT ("'. implode('","', $this->input->get('category_id')) .'
     if ($this->input->get('brand_id')) {
         $product->where('commerce_brand_id IN ("' . implode('","', $this->input->get('brand_id')) . '")');
     }
     if ($this->input->get('q')) {
         $product->like('commerce_products.name', $this->input->get('q'));
     }
     if ($this->input->get('from_price')) {
         $product->like('commerce_products.price >=', $this->input->get('from_price'));
     }
     if ($this->input->get('to_price')) {
         $product->like('commerce_products.price <=', $this->input->get('to_price'));
     }
     if ($this->input->get('sorting')) {
         if ($this->input->get('sorting') == 'name') {
             $product->_order_by['name'] = 'ASC';
         } elseif ($this->input->get('sorting') == 'low_price') {
             $product->_order_by['price'] = 'ASC';
         } elseif ($this->input->get('sorting') == 'heigh_price') {
             $product->_order_by['price'] = 'DESC';
         }
     }
     $this->load->library('pagination');
     $product->_limit = $this->config->get('limit');
     $product->_offset = $offset;
     return $this->render('commerce_search', ['categories' => $category->get(), 'brands' => $brands->get(), 'sorting' => $sorting, 'products' => $product->get(), 'product_model' => $product, 'pagination' => $this->Pagination->generate(['url' => Uri_helper::url('commerce_search/index'), 'total' => $product->get(true), 'limit' => $product->_limit, 'offset' => $product->_offset])]);
 }
예제 #6
0
function commerce()
{
    $cat_model = new \modules\commerce\models\Commerce_categories();
    Brightery::SuperInstance()->load->library('cart');
    return ['categories' => $cat_model->tree(), 'cart' => Brightery::SuperInstance()->cart];
}