Changed a lot LOL
This commit is contained in:
@@ -30,7 +30,7 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await SyncronizeIdsAndSkus();
|
||||
//await AddSkus();
|
||||
// await AddVariants();
|
||||
// await AddVariants();
|
||||
|
||||
return new AutomationJobResult
|
||||
{
|
||||
@@ -43,12 +43,13 @@ namespace PartSource.Automation.Jobs
|
||||
/// </summary>
|
||||
private async Task SyncronizeIdsAndSkus()
|
||||
{
|
||||
IEnumerable<Product> products = await _shopifyClient.Products.Get();
|
||||
IEnumerable<Product> products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
||||
|
||||
_partSourceContext.Database.ExecuteSqlCommand("UPDATE ImportData SET ShopifyId = NULL");
|
||||
//_partSourceContext.Database.ExecuteSqlCommand("UPDATE ImportData SET ShopifyId = NULL");
|
||||
|
||||
while (products != null && products.Any())
|
||||
{
|
||||
|
||||
foreach (Product product in products)
|
||||
{
|
||||
foreach (Variant variant in product.Variants)
|
||||
@@ -62,16 +63,19 @@ namespace PartSource.Automation.Jobs
|
||||
}
|
||||
}
|
||||
|
||||
await _partSourceContext.SaveChangesAsync();
|
||||
|
||||
try
|
||||
{
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
await _partSourceContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
products = await _shopifyClient.Products.GetPrevious();
|
||||
Console.WriteLine("Failed to save a batch of products");
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +89,7 @@ namespace PartSource.Automation.Jobs
|
||||
.ToList();
|
||||
|
||||
// items = items.Where(i => i.Title == items.First().Title).ToList();
|
||||
//
|
||||
//
|
||||
foreach (ImportData importData in items)
|
||||
{
|
||||
try
|
||||
@@ -145,12 +149,12 @@ namespace PartSource.Automation.Jobs
|
||||
Title = importData.Title,
|
||||
Vendor = importData.Vendor,
|
||||
Tags = string.Join(",", productTags),
|
||||
Published = true,
|
||||
//ProductType = importData.FINELINE_NM,
|
||||
Images = productImages.ToArray(),
|
||||
//Variants = productVariants.ToArray(),
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now
|
||||
UpdatedAt = DateTime.Now,
|
||||
PublishedAt = DateTime.Now
|
||||
};
|
||||
|
||||
requestData = await _shopifyClient.Products.Add(requestData);
|
||||
@@ -259,12 +263,12 @@ namespace PartSource.Automation.Jobs
|
||||
Title = items[0].Title,
|
||||
Vendor = items[0].Vendor,
|
||||
Tags = string.Join(",", productTags),
|
||||
Published = true,
|
||||
//ProductType = importData.FINELINE_NM,
|
||||
Images = productImages.ToArray(),
|
||||
//Variants = productVariants.ToArray(),
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now
|
||||
UpdatedAt = DateTime.Now,
|
||||
PublishedAt = DateTime.Now
|
||||
};
|
||||
|
||||
requestData = await _shopifyClient.Products.Add(requestData);
|
||||
|
||||
Reference in New Issue
Block a user