Hi , I have combination sku number , stock and price adjustment so want to change attributes price . Below codes i can updates stocks but cant update price . var combination = _productAttributeService.GetProductVariantAttributeCombinationBySku(sku); combination.StockQuantity = stock; _productAttributeService.UpdateProductVariantAttributeCombination(combination);
How can i update attribute price ? I didnt succes to takes id from AttributesXml column . Can you show me way of it ?
Hi , I have combination sku number , stock and price adjustment so want to change attributes price . Below codes i can updates stocks but cant update price . var combination = _productAttributeService.GetProductVariantAttributeCombinationBySku(sku); combination.StockQuantity = stock; _productAttributeService.UpdateProductVariantAttributeCombination(combination);
How can i update attribute price ? I didnt succes to takes id from AttributesXml column . Can you show me way of it ?
Thanks
Hi ,
You can try like that to take AttributesXml and parse it .
Method 1 : var variantXml = combination.AttributesXml; XmlDocument doc = new XmlDocument(); doc.LoadXml(@variantXml); XmlNode node = doc.SelectSingleNode("//Attributes/ProductVariantAttribute/ProductVariantAttributeValue/Value"); int value = Convert.ToInt32(node.InnerText);
I want to change price on my main pages product ,when i change atributes,doesnt work.
[HttpPost] public ActionResult ProductAttributeCombinationUpdate(ProductModel.ProductAttributeCombinationModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView();
var combination = _productAttributeService.GetProductAttributeCombinationById(model.Id); if (combination == null) throw new ArgumentException("No product attribute combination found with the specified id");
var product = _productService.GetProductById(combination.ProductId); if (product == null) throw new ArgumentException("No product found with the specified id");
//a vendor should have access only to his products if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id) return Content("This is not your product");