|
@@ -28,7 +28,7 @@ class Product < ActiveRecord::Base
|
|
|
COLOR_ENUM = []
|
|
COLOR_ENUM = []
|
|
|
def get_size_enum
|
|
def get_size_enum
|
|
|
SIZE_ENUM.clear
|
|
SIZE_ENUM.clear
|
|
|
- if SIZE_ENUM.length ==0
|
|
|
|
|
|
|
+ if SIZE_ENUM.length ==0 && self.relate_product_id>0
|
|
|
linkSize = ProductAttrConfig.where("product_id=? and size_type='size'",self.relate_product_id).first
|
|
linkSize = ProductAttrConfig.where("product_id=? and size_type='size'",self.relate_product_id).first
|
|
|
if !linkSize.blank?
|
|
if !linkSize.blank?
|
|
|
productAttrs = ProductAttr.where("attr_key_id=?",linkSize.attr_key_id).order("recommend desc")
|
|
productAttrs = ProductAttr.where("attr_key_id=?",linkSize.attr_key_id).order("recommend desc")
|
|
@@ -40,7 +40,7 @@ class Product < ActiveRecord::Base
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
COLOR_ENUM.clear
|
|
COLOR_ENUM.clear
|
|
|
- if COLOR_ENUM.length==0
|
|
|
|
|
|
|
+ if COLOR_ENUM.length==0 && self.relate_product_id>0
|
|
|
linkColor = ProductAttrConfig.where("product_id=? and size_type='color'",self.relate_product_id).first
|
|
linkColor = ProductAttrConfig.where("product_id=? and size_type='color'",self.relate_product_id).first
|
|
|
if !linkColor.blank?
|
|
if !linkColor.blank?
|
|
|
productColorAttrs = ProductAttr.where("attr_key_id=?",linkColor.attr_key_id).order("recommend desc")
|
|
productColorAttrs = ProductAttr.where("attr_key_id=?",linkColor.attr_key_id).order("recommend desc")
|