浏览代码

product cache clear

abiao 4 年之前
父节点
当前提交
0f64aad9a1
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      app/models/product.rb

+ 8 - 0
app/models/product.rb

@@ -13,6 +13,8 @@ class Product < ActiveRecord::Base
     after_create :after_create
     before_save :before_save
     after_destroy :del_picture
+    after_update :clear_product_cache
+
     def after_create
         #主商品默认关联商品
         if self.show_flag
@@ -42,6 +44,12 @@ class Product < ActiveRecord::Base
         end
     end
 
+    def clear_product_cache
+        #清空商品缓存
+        url = "#{CONFIG_FILE["api_host"]}/railsadmin/clean_cache/product/#{self.id}"
+        p url
+        open(url)
+    end
     TYPE_ENUM = [["直营","direct_sale"],["店铺专区","shop_sale"],["积分专区","cent_sale"]]
     SIZE_ENUM =  []
     COLOR_ENUM =  []