private static string GetCustomAttribute(CatalogDataProductInterface catalogDataProductInterface, string attributesCode) { var descriptionNodes = (catalogDataProductInterface.customAttributes.FirstOrDefault(x => string.Equals(x.attributeCode, attributesCode, StringComparison.InvariantCultureIgnoreCase)) ?? new FrameworkAttributeInterface()).value; if (descriptionNodes is XmlNode[]) { var nodeValue = descriptionNodes as XmlNode[]; var temp = new List <string>(); if (nodeValue.Length > 0) { temp.AddRange(from XmlNode xmlNode in nodeValue where xmlNode != null select xmlNode.InnerText); } return(string.Join(",", temp.ToArray())); } else if (descriptionNodes is XmlNode) { var nodeValue = descriptionNodes as XmlNode; string temp = nodeValue.InnerText; return(temp); } else { return(null); } }
public SoapProduct( CatalogDataProductInterface catalogProductEntity ) { Name = catalogProductEntity.name; ProductId = catalogProductEntity.id.ToString( CultureInfo.InvariantCulture ); Sku = catalogProductEntity.sku; this.Type = catalogProductEntity.typeId; }
public SoapProduct(CatalogDataProductInterface catalogProductEntity) { this.Name = catalogProductEntity.name; this.ProductId = catalogProductEntity.id.ToString(CultureInfo.InvariantCulture); this.Sku = catalogProductEntity.sku; this.Type = catalogProductEntity.typeId; this.UpdatedAt = catalogProductEntity.updatedAt; }
private static string GetSimpleStringCustomAttribute(CatalogDataProductInterface catalogDataProductInterface, string attributesCode) { var frameworkAttributeInterface = catalogDataProductInterface.customAttributes.FirstOrDefault(x => string.Equals(x.attributeCode, attributesCode, StringComparison.InvariantCultureIgnoreCase)) ?? new FrameworkAttributeInterface(); var descriptionNodes = frameworkAttributeInterface.value as XmlNode[]; string temp = null; if (descriptionNodes != null && descriptionNodes.Length > 0) { temp = string.Join("", descriptionNodes.Where(x => x != null).Select(x => x.InnerText)); } return(temp); }
private static string[] GetArrayOfStringCustomAttribute(CatalogDataProductInterface catalogDataProductInterface, string attributesCode) { var frameworkAttributeInterfaces = catalogDataProductInterface.customAttributes; var firstOrDefault = frameworkAttributeInterfaces.FirstOrDefault(x => string.Equals(x.attributeCode, attributesCode, StringComparison.InvariantCultureIgnoreCase)); var frameworkAttributeInterface = firstOrDefault != null ? firstOrDefault : new FrameworkAttributeInterface(); var descriptionNodes = frameworkAttributeInterface.value as XmlNode[]; var temp = new List <string>(); if (descriptionNodes != null && descriptionNodes.Length > 0) { temp.AddRange(from XmlNode node in descriptionNodes where node != null select node.InnerText); } return(temp.ToArray()); }
public async Task <int> CreateProduct(string storeId, string name, string sku, int isInStock, string productType, Mark markForLog) { var stockItem = new CreatteProductModel(name, sku, isInStock, productType); var methodParameters = stockItem.ToJson(); try { const int maxCheckCount = 2; const int delayBeforeCheck = 1800000; var privateClient = this._clientFactory.CreateMagentoCatalogProductRepositoryServiceClient(); var res = new List <RpcInvoker.RpcResponse <catalogProductRepositoryV1SaveResponse1> >(); var stockItems = new List <CreatteProductModel> { stockItem }; await stockItems.DoInBatchAsync(10, async x => { await ActionPolicies.GetAsync.Do(async() => { var statusChecker = new StatusChecker(maxCheckCount); TimerCallback tcb = statusChecker.CheckStatus; privateClient = this._clientFactory.RefreshMagentoCatalogProductRepositoryServiceClient(privateClient); using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck)) { MagentoLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark: markForLog)); var catalogInventoryDataStockItemInterface = new CatalogDataProductInterface() { sku = x.Sku, name = x.Name, price = "1", priceSpecified = true, status = 1, statusSpecified = true, typeId = productType, attributeSetId = 4, attributeSetIdSpecified = true, weight = "1", weightSpecified = true, }; if (productType == "bundle") { catalogInventoryDataStockItemInterface.customAttributes = new[] { new FrameworkAttributeInterface { value = "1", attributeCode = "price_view" }, new FrameworkAttributeInterface { value = "1", attributeCode = "price_type" } }; } var catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest = new CatalogProductRepositoryV1SaveRequest() { product = catalogInventoryDataStockItemInterface }; var temp = await privateClient.catalogProductRepositoryV1SaveAsync(catalogInventoryStockRegistryV1UpdateStockItemBySkuRequest).ConfigureAwait(false); var updateResult = new RpcInvoker.RpcResponse <catalogProductRepositoryV1SaveResponse1>(RpcInvoker.SoapErrorCode.Success, temp, null); res.Add(updateResult); } }).ConfigureAwait(false); }).ConfigureAwait(false); MagentoLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark: markForLog, methodResult: res.ToJson())); return(res.First().Result.catalogProductRepositoryV1SaveResponse.result.id); } catch (Exception exc) { throw new MagentoSoapException($"An error occured during PutStockItemsAsync({methodParameters})", exc); } }