Skip to content

Commit ea85add

Browse files
committed
Align view models with recent PRs on Shopify
1 parent d345253 commit ea85add

File tree

7 files changed

+71
-3
lines changed

7 files changed

+71
-3
lines changed

src/Umbraco.Cms.Integrations.Commerce.Shopify/Editors/ShopifyProductPickerValueConverter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,24 @@ public override object ConvertIntermediateToObject(IPublishedElement owner, IPub
4848
Id = p.Id,
4949
Title = p.Title,
5050
Body = p.Body,
51-
Image = p.Image?.Src
51+
ProductImage = p.Image != null ? new ProductImageViewModel { Src = p.Image.Src, Alt = p.Image.Alt } : null,
52+
Tags = p.Tags,
53+
ProductType = p.ProductType,
54+
PublishedScope = p.PublishedScope,
55+
Handle = p.Handle,
56+
Status = p.Status,
57+
Variants = from v in p.Variants
58+
select new VariantViewModel
59+
{
60+
InventoryQuantity = v.InventoryQuantity,
61+
Position = v.Position,
62+
Price = v.Price,
63+
Sku = v.Sku,
64+
Taxable = v.Taxable
65+
}
5266
};
5367

68+
5469
return products.ToList();
5570
}
5671
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/ProductDto.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ public class ProductDto
2525

2626
[JsonPropertyName("image")]
2727
public ProductImageDto Image { get; set; }
28-
}
2928

29+
[JsonPropertyName("product_type")]
30+
public string ProductType { get; set; }
31+
32+
[JsonPropertyName("published_scope")]
33+
public string PublishedScope { get; set; }
3034

35+
[JsonPropertyName("handle")]
36+
public string Handle { get; set; }
37+
}
3138
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/ProductImageDto.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ public class ProductImageDto
44
{
55
[JsonPropertyName("src")]
66
public string Src { get; set; }
7+
8+
[JsonPropertyName("alt")]
9+
public string Alt { get; set; }
710
}
811
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/ProductVariantDto.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ public class ProductVariantDto
1616

1717
[JsonPropertyName("inventory_quantity")]
1818
public int InventoryQuantity { get; set; }
19+
20+
21+
[JsonPropertyName("taxable")]
22+
public bool Taxable { get; set; }
1923
}
2024
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels
2+
{
3+
public class ProductImageViewModel
4+
{
5+
public string Src { get; set; }
6+
7+
public string Alt { get; set; }
8+
}
9+
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/ViewModels/ProductViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ public class ProductViewModel
99

1010
public string Body { get; set; }
1111

12-
public string Image { get; set; }
12+
public string Image => ProductImage.Src;
13+
14+
public ProductImageViewModel ProductImage { get; set; }
15+
16+
public string ProductType { get; set; }
17+
18+
public string Tags { get; set; }
19+
20+
public string Status { get; set; }
21+
22+
public string PublishedScope { get; set; }
23+
24+
public string Handle { get; set; }
25+
26+
public IEnumerable<VariantViewModel> Variants { get; set; }
1327
}
1428
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels
2+
{
3+
public class VariantViewModel
4+
{
5+
public string Price { get; set; }
6+
7+
public string Sku { get; set; }
8+
9+
public int Position { get; set; }
10+
11+
public int InventoryQuantity { get; set; }
12+
13+
public bool Taxable { get; set; }
14+
15+
}
16+
}

0 commit comments

Comments
 (0)