Skip to content

Commit e02bd8c

Browse files
authored
Merge pull request #5 from time-frame/master
Fixed ItemSpecific bug on product model
2 parents 86faf1f + 30d69d3 commit e02bd8c

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

NetoDotNET.Examples/Program.cs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ static void Main(string[] args)
3737
var neto = new StoreManager(config.GetSection("NETO_STORE_URL").Value, config.GetSection("NETO_API_KEY").Value, config.GetSection("NETO_USERNAME").Value);
3838

3939
#region Products
40-
GetItems(neto);
40+
//GetItems(neto);
4141
//GetItemsFromDate(neto);
4242

4343
// AddItems(neto);
44-
//AddVariableItems(neto);
44+
AddVariableItems(neto);
4545

4646
//UpdateItems(neto);
4747
#endregion
@@ -800,19 +800,51 @@ static void AddVariableItems(StoreManager neto)
800800
new NewItem {
801801
Name = "Variable Item",
802802
SKU = "VAR",
803-
DefaultPrice = 1.00m,
803+
DefaultPrice = 1.00m
804804
},
805805
new NewItem {
806806
Name = "Variable Item",
807807
SKU = "VAR1",
808808
DefaultPrice = 1.00m,
809-
ParentSKU = "VAR"
809+
ParentSKU = "VAR",
810+
ItemSpecifics = new ItemSpecifics
811+
{
812+
ItemSpecific = new List<ItemSpecific>
813+
{
814+
new ItemSpecific()
815+
{
816+
Name = "Size",
817+
Value = "1"
818+
},
819+
new ItemSpecific()
820+
{
821+
Name = "Colour",
822+
Value = "RED"
823+
}
824+
}
825+
}
810826
},
811827
new NewItem {
812828
Name = "Variable Item",
813829
SKU = "VAR2",
814830
DefaultPrice = 1.00m,
815-
ParentSKU = "VAR"
831+
ParentSKU = "VAR",
832+
ItemSpecifics = new ItemSpecifics
833+
{
834+
ItemSpecific = new List<ItemSpecific>
835+
{
836+
new ItemSpecific()
837+
{
838+
Name = "Size",
839+
Value = "2"
840+
},
841+
new ItemSpecific()
842+
{
843+
Name = "Colour",
844+
Value = "RED"
845+
}
846+
}
847+
}
816848
}
817849
};
818850

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"NETO_STORENAME": "<YOUR_NETO_STORE_URL>",
2+
"NETO_STORE_URL": "<YOUR_NETO_STORE_URL>",
33
"NETO_API_KEY": "<YOUR_NETO_API_KEY>",
44
"NETO_USERNAME": "<YOUR_NETO_USERNAME>"
55
}

NetoDotNET/Entities/Product/ItemBase.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ public class ItemBase
370370
[JsonConverter(typeof(SingleOrArrayConverter<CategoryProduct>))]
371371
public List<CategoryProduct> Categories { get; set; }
372372

373-
[JsonConverter(typeof(SingleOrArrayConverter<ItemSpecific>))]
374-
public List<ItemSpecific> ItemSpecifics { get; set; }
373+
public ItemSpecifics ItemSpecifics { get; set; }
374+
375375
[JsonConverter(typeof(SingleOrArrayConverter<WarehouseQuantity>))]
376376
public List<WarehouseQuantity> WarehouseQuantity { get; set; }
377377

@@ -382,6 +382,8 @@ public class ItemBase
382382
public List<RelatedContents> RelatedContents { get; set; }
383383
}
384384

385+
386+
385387
public class WarehouseQuantity
386388
{
387389
public string WarehouseID { get; set; }
@@ -430,13 +432,15 @@ public class PriceGroup
430432

431433
public class ItemSpecifics
432434
{
433-
public ItemSpecific ItemSpecific { get; set; }
435+
[JsonConverter(typeof(SingleOrArrayConverter<ItemSpecific>))]
436+
public List<ItemSpecific> ItemSpecific { get; set; }
434437
}
435438

436439
public class ItemSpecific
437440
{
438441
public string Name { get; set; }
439442
public string Value { get; set; }
443+
public int SortOrder { get; set; }
440444

441445
}
442446

NetoDotNET/NetoDotNET.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
<Version>0.2.2</Version>
1818
</PropertyGroup>
1919

20+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<DebugType>full</DebugType>
23+
<DebugSymbols>true</DebugSymbols>
24+
</PropertyGroup>
25+
2026
<ItemGroup>
2127
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
2228
<Reference Include="Newtonsoft.Json">

0 commit comments

Comments
 (0)