/// <summary> /// Performs the sync for Magento products orders to Endless Aisle. /// </summary> /// <returns>If the sync was susscessful</returns> private static bool ProductSync() { try { var lastSync = GetTimeForSync(Log.ProductSync); var productsToUpdate = _productMapper.GetMagentoProductsUpdatedAfter(lastSync).ToList(); if (!productsToUpdate.Any()) { Console.WriteLine("No products to update."); } foreach (var newProduct in productsToUpdate) { lastSync = newProduct.updated_at > lastSync ? newProduct.updated_at : lastSync; UpsertProduct(_productMapper.GetProductBySku(newProduct.sku)); Console.WriteLine("Product with SKU {0} has been updated.", newProduct.sku); } LogUtility.Write(Log.ProductSync, string.Format("Products successfully synced. Last product synced was updated at {0}", lastSync)); return(true); } catch (Exception ex) { LogException(ex); //Uncomment if you want exceptions thrown at runtime. //throw; } return(false); }