예제 #1
0
 function getProductHome()
 {
     $productHome = new producthome();
     $productHome->where_related_product('active', 1);
     $productHome->where('productcat_id', $this->id);
     $productHome->order_by('position', 'asc');
     $productHome->get_iterated($this->numProductHomepage);
     return $productHome;
 }
예제 #2
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new producthome();
         $o->where("productcat_id", $this->productcat_id);
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
         $o->clear();
         $o = new producthome();
         $o->where('productcat_id', $this->productcat_id);
         $o->where('product_id', $this->product_id);
         $o->get();
         if ($o->exists()) {
             return true;
         }
     }
     return parent::save($object, $related_field);
 }
예제 #3
0
 function addProductHome($productCatId)
 {
     $productCat = new productcat($productCatId);
     $arr = $this->input->post('productCheck');
     if ($arr != "") {
         foreach ($arr as $row) {
             $productHomeItem = new producthome();
             $productHomeItem->productcat_id = $productCatId;
             $productHomeItem->product_id = $row;
             $productHomeItem->save();
             $productHomeItem->clear();
         }
     }
     $productHome = new producthome();
     $productHome->where('productcat_id', $productCatId);
     $productHome->order_by('position', 'asc');
     $productHome->get_iterated();
     $dis['object'] = $productCat;
     $dis['productHome'] = $productHome;
     $dis['base_url'] = base_url();
     echo $this->load->view('admin/productcats/tabs/productHome', $dis, true);
     exit;
 }