Esempio n. 1
0
 /**
  * 通过商品ID删除商品
  *
  * @param integer $product_id
  * @return boolean
  */
 public static function delete($product_id)
 {
     $product = ProductService::get_instance()->get($product_id);
     if (!$product['id'] > 0) {
         throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400);
     }
     switch ($product['type']) {
         case ProductService::PRODUCT_TYPE_ASSEMBLY:
         case ProductService::PRODUCT_TYPE_CONFIGURABLE:
             self::delete_goods($product_id);
             break;
         case ProductService::PRODUCT_TYPE_GOODS:
             BLL_Product_Type_Simple::delete($product_id);
             break;
     }
     BLL_Product_Picture::delete($product_id);
     BLL_Product_Wholesale::delete($product_id);
     BLL_Product_Relation::delete($product_id);
     BLL_Product_Detail::delete($product_id);
     //BLL_Product_Point::delete($product_id);
     BLL_Product_Search::delete($product_id);
     //BLL_Product_Argument::rmv_arguments($product_id);
     ORM::factory('productcomment')->where('product_id', $product_id)->delete_all();
     ORM::factory('productinquiry')->where('product_id', $product_id)->delete_all();
     ProductService::get_instance()->remove($product_id);
     //Cache::remove(self::$cache_key.$product_id);
     //Cache::remove('product_inquiries.'.$product_id);
     //Cache::remove('product_comments.'.$product_id);
     return TRUE;
 }