@@ -115,6 +115,8 @@ public static Product AsWebModel(
115
115
116
116
var variant = product . AsVariantWebModel ( productPrice , options , productRewards , productInventory ) ;
117
117
118
+ variant . Title = "Default Title" ;
119
+
118
120
productModel . Variants . Add ( variant ) ;
119
121
120
122
return productModel ;
@@ -148,7 +150,7 @@ public static Variant AsVariantWebModel(this Data.CatalogItem variation, Data.Pr
148
150
variantModel . Image = variationImage != null ? variationImage . AsWebModel ( variation . Name , variation . MainProductId ) : null ;
149
151
150
152
PopulateInventory ( ref variantModel , variation , inventory ) ;
151
- variantModel . AllOptions = GetOptionValues ( options , variation . VariationProperties ) ;
153
+ variantModel . Options = GetOptionValues ( options , variation . VariationProperties ) ;
152
154
153
155
variantModel . NumericPrice = price != null ? ( price . Sale . HasValue ? price . Sale . Value : price . List ) : 0M ;
154
156
if ( reward != null )
@@ -219,18 +221,32 @@ public static Review AsWebModel(this Data.Review review)
219
221
return webReview ;
220
222
}
221
223
224
+ #region Option Methods
225
+
226
+ private static string DefaultOption = "Default Title" ;
222
227
private static string [ ] GetOptions ( IDictionary < string , object > itemProperties )
223
228
{
224
229
if ( itemProperties == null || ! itemProperties . Any ( ) )
225
230
{
226
- return null ;
231
+ return new [ ] { "Title" } ;
227
232
}
228
233
229
- return itemProperties . Select ( o => o . Key ) . ToArray ( ) ;
234
+ var options = itemProperties . Select ( o => o . Key ) . ToArray ( ) ;
235
+ if ( options == null || ! options . Any ( ) )
236
+ {
237
+ options = new [ ] { "Title" } ;
238
+ }
239
+
240
+ return options ;
230
241
}
231
242
232
243
private static string [ ] GetOptionValues ( IEnumerable < string > options , IDictionary < string , object > itemProperties )
233
244
{
245
+ if ( options != null && options . Count ( ) == 1 && options . ElementAt ( 0 ) == "Title" )
246
+ {
247
+ return new [ ] { DefaultOption } ;
248
+ }
249
+
234
250
if ( itemProperties == null || ! itemProperties . Any ( ) || options == null )
235
251
{
236
252
return null ;
@@ -239,6 +255,7 @@ private static string[] GetOptionValues(IEnumerable<string> options, IDictionary
239
255
var variationOptions = options . Select ( option => itemProperties . ContainsKey ( option ) ? itemProperties [ option ] . ToNullOrString ( ) : null ) . ToList ( ) ;
240
256
return variationOptions . ToArray ( ) ;
241
257
}
258
+ #endregion
242
259
243
260
private static UrlHelper GetUrlHelper ( )
244
261
{
0 commit comments