Quellcode durchsuchen

增加商品属性定义

abiao vor 5 Jahren
Ursprung
Commit
8e5148b4e8
1 geänderte Dateien mit 14 neuen und 1 gelöschten Zeilen
  1. 14 1
      app/models/product.rb

+ 14 - 1
app/models/product.rb

@@ -9,6 +9,15 @@ class Product < ActiveRecord::Base
     TYPE_ENUM = [["直营","direct_sale"]]
     TYPE_ENUM = [["直营","direct_sale"]]
     #["代销","user_sale"]
     #["代销","user_sale"]
 
 
+    SIZE_ENUM =  []
+    def get_size_enum
+        @Size = ProductAttrConfig.where("product_id=? and type='size'",self.id).first
+        @productAttrs = ProductAttr.where("attr_key_id=?",@Size.id).order("recommend desc")
+        @productAttrs.each do |attr|
+            a=[attr.name,attr.id]
+            SIZE_ENUM.push(a)
+        end
+    end
     IMG_STORE_PATH = "product"
     IMG_STORE_PATH = "product"
 
 
     def v_share_img=file
     def v_share_img=file
@@ -95,7 +104,11 @@ class Product < ActiveRecord::Base
             end
             end
             field :is_only_new
             field :is_only_new
             field :video_state
             field :video_state
-            field :size_id
+            field :size_id, :enum do
+                enum do
+                    SIZE_ENUM
+                end
+            end
             field :color_id
             field :color_id
             field :relate_product_id
             field :relate_product_id
             field :show_flag
             field :show_flag