Sfoglia il codice sorgente

Product model

- get rid of unneeded property 'variants' in selection
Alexey Kim 2 anni fa
parent
commit
3b3816bd35
2 ha cambiato i file con 24 aggiunte e 30 eliminazioni
  1. 1 1
      db/product.go
  2. 23 29
      relation/product.go

+ 1 - 1
db/product.go

@@ -18,7 +18,7 @@ var (
 	productSelection = func(ln model.LanguageCode) []string {
 		return append([]string{
 			"id", "handle", "type", "scope", "tags", "vendor",
-			"collections", "images", "options", "variants",
+			"collections", "images", "options",
 			"created_at", "updated_at", "published_at", "deleted_at",
 		},
 			ln.SqlFieldSelection("title", ""),

+ 23 - 29
relation/product.go

@@ -27,44 +27,38 @@ type Product struct {
 	Collections    []string       `db:"collections"`
 	Images         []string       `db:"images"`
 	Options        []string       `db:"options"`
-	Variants       []string       `db:"variants"`
 }
 
 func (p *Product) As() *generated.Product {
 	description := bluemonday.StrictPolicy().Sanitize(p.Description.String)
 	product := generated.Product{
-		AvailableForSale:    false,
-		Collections:         nil,
-		CompareAtPriceRange: nil,
-		CreatedAt:           scalar.NewDateTimeFrom(p.CreatedAt),
-		Description:         description,
-		DescriptionHTML:     scalar.Html(p.Description.String),
-		FeaturedImage:       nil,
-		Handle:              p.Handle.String,
-		ID:                  model.NewId(model.GidProduct, p.Id),
-		Images:              nil,
-		IsGiftCard:          false,
-		Media:               nil,
-		Metafield:           nil,
-		Metafields:          nil,
-		OnlineStoreURL:      nil,
-		Options:             nil,
-		PriceRange:          nil,
-		ProductType:         p.Type.String,
-		PublishedAt:         0,
-		RequiresSellingPlan: false,
-		SellingPlanGroups:   nil,
+		AvailableForSale:         false,
+		CompareAtPriceRange:      nil,
+		FeaturedImage:            nil,
+		Images:                   nil,
+		IsGiftCard:               false,
+		Media:                    nil,
+		OnlineStoreURL:           nil,
+		PriceRange:               nil,
+		RequiresSellingPlan:      false,
+		SellingPlanGroups:        nil,
+		TotalInventory:           nil,
+		VariantBySelectedOptions: nil,
+
+		ID:              model.NewId(model.GidProduct, p.Id),
+		Handle:          p.Handle.String,
+		Title:           p.Title,
+		Vendor:          p.Vendor.String,
+		Description:     description,
+		DescriptionHTML: scalar.Html(p.Description.String),
+		ProductType:     p.Type.String,
+		Tags:            p.Tags,
 		Seo: &generated.Seo{
 			Description: &description,
 			Title:       &p.Title,
 		},
-		Tags:                     p.Tags,
-		Title:                    p.Title,
-		TotalInventory:           nil,
-		UpdatedAt:                scalar.NewDateTimeFrom(p.UpdatedAt),
-		VariantBySelectedOptions: nil,
-		Variants:                 nil,
-		Vendor:                   p.Vendor.String,
+		CreatedAt: scalar.NewDateTimeFrom(p.CreatedAt),
+		UpdatedAt: scalar.NewDateTimeFrom(p.UpdatedAt),
 	}
 
 	if p.PublishedAt != nil {