|
|
@@ -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
|