public function deleteCategory($del_category_id)
 {
     // check category exist or not
     if (!$this->isCategoryExists($del_category_id)) {
         $result_arr = array('err' => true, 'err_msg' => trans('webshoppack::admin/manageCategory.delete-category.category_not_found_msg'));
         return $result_arr;
     }
     // check products added for the selected category or its subcategories
     if ($this->isCategoryProductExists($del_category_id)) {
         $result_arr = array('err' => true, 'err_msg' => trans('webshoppack::admin/manageCategory.delete-category.category_in_use_msg'));
         return $result_arr;
     }
     // delete category details in all assigned attributes & category image.
     $cat_sub_category_ids = explode(',', $this->sub_category_ids);
     $cat_details = ProductCategory::whereIn('id', $cat_sub_category_ids)->get(array('id', 'image_name', 'image_ext'));
     if (count($cat_details) > 0) {
         foreach ($cat_details as $cat) {
             // Delete all attributes assigned to the selected category & its subcategories
             ProductCategoryAttributes::whereRaw('category_id = ?', array($cat->id))->delete();
             // Delete category image
             $this->deleteImageFiles($cat->image_name, $cat->image_ext, \Config::get("webshoppack::product_category_image_folder"));
         }
     }
     //store the values of the left and right of the category to be deleted
     //delete all those cateogries b/w the above 2
     // update the cateogies to the right of the deleted category  - reduce left and right bu width of the deleted category
     $cat_info = ProductCategory::Select('category_left', 'category_right')->whereRaw('id = ?', array($del_category_id))->first();
     if (count($cat_info) > 0) {
         $category_left = $cat_info['category_left'];
         $category_right = $cat_info['category_right'];
         $width = $category_right - $category_left + 1;
         ProductCategory::whereRaw(\DB::raw('category_left  between  ' . $category_left . ' AND ' . $category_right))->delete();
         //To update category left
         ProductCategory::whereRaw(\DB::raw('category_left >  ' . $category_right))->update(array("category_left" => \DB::raw('category_left - ' . $width)));
         //To update category right
         ProductCategory::whereRaw(\DB::raw('category_right >  ' . $category_right))->update(array("category_right" => \DB::raw('category_right - ' . $width)));
     }
     $result_arr = array('err' => false, 'err_msg' => '', 'category_id' => $del_category_id);
     return $result_arr;
 }
 public function updateListRowOrder($input_arr)
 {
     foreach ($input_arr['attrdnd'] as $display_order => $attribute_id_str) {
         $temp = explode("_", $attribute_id_str);
         $attribute_id = isset($temp[1]) && $temp[1] ? (int) $temp[1] : false;
         $category_id = $input_arr['category_id'];
         if ($attribute_id) {
             $data_arr['display_order'] = $display_order;
             ProductCategoryAttributes::whereRaw('attribute_id = ? AND category_id = ?', array($attribute_id, $category_id))->update($data_arr);
         }
     }
 }
Ejemplo n.º 3
0
 public function checkProductHasAttributeTab($category_id)
 {
     $category_ids = $this->getAllTopLevelCategoryIds($category_id);
     $cat_arr = explode(',', $category_ids);
     if (count($cat_arr) > 0) {
         $a_count = ProductCategoryAttributes::whereIn('category_id', $cat_arr)->count();
         if ($a_count > 0) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 protected function create($id)
 {
     return ProductCategoryAttributes::create($id);
     //create product attribute
 }