Browse Source

增加商品属性定义

abiao 5 years ago
parent
commit
8435fe26c3
1 changed files with 6 additions and 4 deletions
  1. 6 4
      app/models/product.rb

+ 6 - 4
app/models/product.rb

@@ -12,10 +12,12 @@ class Product < ActiveRecord::Base
     SIZE_ENUM =  []
     def get_size_enum
         @Size = ProductAttrConfig.where("product_id=? and size_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)
+        if !@Size.blank?
+            @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
     end
     IMG_STORE_PATH = "product"