|
@@ -25,19 +25,41 @@ type ProductCollection struct {
|
|
|
}
|
|
|
|
|
|
func (c *ProductCollection) As() *generated.Collection {
|
|
|
- description := bluemonday.StrictPolicy().Sanitize(c.Description)
|
|
|
- return &generated.Collection{
|
|
|
- Description: description,
|
|
|
- DescriptionHTML: scalar.Html(c.Description),
|
|
|
- Handle: c.Handle.String,
|
|
|
- ID: model.NewId(model.GidCollection, c.Id),
|
|
|
- Image: nil, //TODO:
|
|
|
- OnlineStoreURL: nil, //TODO:
|
|
|
- Seo: &generated.Seo{
|
|
|
- Description: &description,
|
|
|
- Title: &c.Title,
|
|
|
- },
|
|
|
- Title: c.Title,
|
|
|
- UpdatedAt: scalar.NewDateTimeFrom(c.UpdatedAt),
|
|
|
+ var (
|
|
|
+ description = bluemonday.StrictPolicy().Sanitize(c.Description)
|
|
|
+ collection = &generated.Collection{
|
|
|
+ Description: description,
|
|
|
+ DescriptionHTML: scalar.Html(c.Description),
|
|
|
+ Handle: c.Handle.String,
|
|
|
+ ID: model.NewId(model.GidCollection, c.Id),
|
|
|
+ Image: nil, //TODO:
|
|
|
+ OnlineStoreURL: nil, //TODO:
|
|
|
+ Seo: &generated.Seo{
|
|
|
+ Description: &description,
|
|
|
+ Title: &c.Title,
|
|
|
+ },
|
|
|
+ Title: c.Title,
|
|
|
+ UpdatedAt: scalar.NewDateTimeFrom(c.UpdatedAt),
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ if order := generated.CollectionSortOrder(c.SortOrder); order.IsValid() {
|
|
|
+ collection.Metafields = append(collection.Metafields, &generated.Metafield{
|
|
|
+ Namespace: model.GidCollection.String(),
|
|
|
+ Key: "sort_order",
|
|
|
+ Type: model.MetaFieldTypeSingleLineTextField.String(),
|
|
|
+ Value: order.String(),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if scope := model.PublishScope(c.Scope); scope.IsValid() {
|
|
|
+ collection.Metafields = append(collection.Metafields, &generated.Metafield{
|
|
|
+ Namespace: model.GidCollection.String(),
|
|
|
+ Key: "scope",
|
|
|
+ Type: model.MetaFieldTypeSingleLineTextField.String(),
|
|
|
+ Value: scope.String(),
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+ return collection
|
|
|
}
|