Parcourir la source

商品规格更改返回

abiao il y a 5 ans
Parent
commit
e9cf6636a6

+ 4 - 3
go/gopath/src/fohow.com/apps/controllers/product_controller/product_controller.go

@@ -302,7 +302,7 @@ func (self *ProductController) GetProductSizesByPid() {
 
 	ret := &Ret{}
 	if product != nil {
-		list := product_model.GetProductConfigAttrsByPId(pId)
+		list := product_model.GetProductConfigAttrsByPId(product.RelateProductId)
 		for _, item := range list {
 			attrTypeList := []*product_model.ProductAttr{}
 			productKeyConfig := product_model.GetProductAttrKey(item.AttrKeyId)
@@ -311,9 +311,10 @@ func (self *ProductController) GetProductSizesByPid() {
 					attrList := product_model.GetProductAttrsByKId(productKeyConfig.Id)
 					for _, attr := range attrList {
 						prod := product_model.GetProductByIdAndSizeId(product.RelateProductId, attr.Id, true)
-						if prod != nil {
-							attrTypeList = append(attrTypeList, attr)
+						if prod == nil {
+							continue
 						}
+						attrTypeList = append(attrTypeList, attr)
 					}
 					productKeyConfig.ProductAttr = attrTypeList
 					ret.Size = productKeyConfig

+ 2 - 4
go/gopath/src/fohow.com/apps/models/product_model/product.go

@@ -340,8 +340,7 @@ func GetProductByIdAndSizeId(relateId, sizeId int64, useCache bool) *Product {
 	if err := o.QueryTable(item).Filter("relate_product_id", relateId).Filter("size_id", sizeId).One(item); err != nil {
 		return nil
 	}
-	item.Cover = GetCoverByPId(relateId, useCache)
-	cache.Cache.Put(k, item, 5*time.Minute)
+
 	return item
 }
 
@@ -358,7 +357,6 @@ func GetProductByIdAndColorId(relateId, colorId int64, useCache bool) *Product {
 	if err := o.QueryTable(item).Filter("relate_product_id", relateId).Filter("color_id", colorId).One(item); err != nil {
 		return nil
 	}
-	item.Cover = GetCoverByPId(relateId, useCache)
-	cache.Cache.Put(k, item, 5*time.Minute)
+
 	return item
 }