Explorar el Código

增加商品属性定义

abiao hace 5 años
padre
commit
9365a46c3b
Se han modificado 1 ficheros con 7 adiciones y 6 borrados
  1. 7 6
      app/models/product.rb

+ 7 - 6
app/models/product.rb

@@ -13,21 +13,22 @@ class Product < ActiveRecord::Base
     def get_size_enum
         SIZE_ENUM.clear
         if SIZE_ENUM.length ==0
-            @Size = ProductAttrConfig.where("product_id=? and size_type='size'",self.id).first
-            if !@Size.blank?
-                @productAttrs = ProductAttr.where("attr_key_id=?",@Size.id).order("recommend desc")
-                @productAttrs.each do |attr|
+            linkSize = ProductAttrConfig.where("product_id=? and size_type='size'",self.id).first
+            if !linkSize.blank?
+                productAttrs = ProductAttr.where("attr_key_id=?",linkSize.id).order("recommend desc")
+                productAttrs.each do |attr|
                     a=[attr.name,attr.id]
                     SIZE_ENUM.push(a)
                 end
             end
         end
+
         COLOR_ENUM.clear
         if COLOR_ENUM.length==0
             linkColor = ProductAttrConfig.where("product_id=? and size_type='color'",self.id).first
             if !linkColor.blank?
-                @productColorAttrs = ProductAttr.where("attr_key_id=?",linkColor.id).order("recommend desc")
-                @productColorAttrs.each do |color_attr|
+                productColorAttrs = ProductAttr.where("attr_key_id=?",linkColor.id).order("recommend desc")
+                productColorAttrs.each do |color_attr|
                     b=[color_attr.name,color_attr.id]
                     COLOR_ENUM.push(b)
                 end