Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.21.6</Version>
<Version>10.21.7</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public virtual void FillProductValues(ProductInfo productInfo, Product product,
productPrice.PriceWithVAT = price.PriceWithVAT;

// Update Product Custom Fields
if (settings.AddProductFieldsToRequest && product.ProductFieldValues.Count > 0)
if (settings.AddProductFieldsToRequest)
Comment thread
DWDBE marked this conversation as resolved.
{
FillProductFieldValues(product, productInfo);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Extensions;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products;
using Dynamicweb.Ecommerce.Orders;
using Dynamicweb.Ecommerce.ProductCatalog;
using Dynamicweb.Ecommerce.Products;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -102,7 +105,7 @@ public static bool UpdateProduct(Product product, double quantity, string curren
var productSelection = product.GetPriceProductSelection(1, null);
var context = new LiveContext(Services.Currencies.GetCurrency(currencyCode), Helpers.GetCurrentExtranetUser(), Services.Shops.GetShop(shopId));
return Products.ProductManager.FetchProductInfos(
new List<Prices.PriceProductSelection>(){ productSelection },
new List<Prices.PriceProductSelection>() { productSelection },
context,
settings, new Logging.Logger(settings), false, SubmitType.Live, updateCache);
}
Expand All @@ -122,6 +125,46 @@ public static bool IsLazyLoadingForProductInfoEnabled
&& (user == null || !user.IsLiveIntegrationPricesDisabled())
&& settings.LazyLoadProductInfo;
}
}
}

/// <summary>
/// Updates the product fields in the specified product view model with live information from the ERP.
/// </summary>
/// <param name="product">The product view model.</param>
public static void UpdateProductInViewModel(ProductViewModel product)
{
var shopId = Global.CurrentShopId;
var settings = SettingsManager.GetSettingsByShop(shopId);
if (settings == null)
return;

var user = Helpers.GetCurrentExtranetUser();
var loadedProduct = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId);
if (loadedProduct == null || !Helpers.CanCheckPrice(settings, loadedProduct, user))
return;

var logger = new Logging.Logger(settings);
bool showVariantDefault = SystemConfiguration.Instance.GetBoolean("/Globalsettings/Ecom/Product/ShowVariantDefault");
var productForRequest = showVariantDefault ? ProductManager.ProductProvider.GetProductFromVariantComboId(loadedProduct, logger) : loadedProduct;
Comment thread
DWDBE marked this conversation as resolved.
Comment thread
DWDBE marked this conversation as resolved.
productForRequest = productForRequest ?? loadedProduct;

var context = new LiveContext(Helpers.GetCurrentCurrency(), user, null);
Comment thread
DWDBE marked this conversation as resolved.
string unitId = settings.UseUnitPrices ? productForRequest.DefaultUnitId : null;
var productSelection = productForRequest.GetPriceProductSelection(1, unitId);

var productInfo = ProductManager.GetProductInfo(productForRequest, settings, user);
Comment thread
DWDBE marked this conversation as resolved.
if (productInfo == null)
{
if (!ProductManager.FetchProductInfos([productSelection], context, settings, logger, false, SubmitType.Live, true))
return;

productInfo = ProductManager.GetProductInfo(productForRequest, settings, user);
}

if (productInfo == null)
return;

ProductManager.ProductProvider.FillProductValues(productInfo, loadedProduct, settings, productSelection.Quantity, context);
Comment thread
DWDBE marked this conversation as resolved.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private XmlNode BuildProductInfoXml(Settings currentSettings, XmlDocument xmlDoc
AddChildXmlNode(itemNode, "CurrencyCode", currencyCode);
AddChildXmlNode(itemNode, "Quantity", productWithQuantity.Quantity.ToIntegrationString(currentSettings, logger));

if (settings.AddProductFieldsToRequest && product.ProductFieldValues.Count > 0)
if (settings.AddProductFieldsToRequest)
Comment thread
DWDBE marked this conversation as resolved.
{
AppendProductFields(currentSettings, product, itemNode, logger);
}
Expand Down
Loading