Attribute Price Change

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
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
9 years ago
Anyone have idea ?

Thanks
9 years ago
Hi ,
I searched have parse method which _productAttributeParser.ParseValues  but it is not working .

I still trying to parse to AttributeXml column have any method i miss ?

Anyone can write something ?
9 years ago
?
9 years ago
newdew wrote:
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);


Hope this help you .

Thank you .
9 years ago
Thank you .
8 years ago
what name method for change price?
8 years ago
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");

            combination.StockQuantity = model.StockQuantity;
            combination.AllowOutOfStockOrders = model.AllowOutOfStockOrders;
            combination.Sku = model.Sku;
            combination.ManufacturerPartNumber = model.ManufacturerPartNumber;
            combination.Gtin = model.Gtin;
            combination.OverriddenPrice = model.OverriddenPrice;
            combination.NotifyAdminForQuantityBelow = model.NotifyAdminForQuantityBelow;
         //price
            var variantXml = combination.AttributesXml;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(@variantXml);
            System.Xml.XmlNode node = doc.SelectSingleNode("//Attributes/ProductVariantAttribute/ProductVariantAttributeValue/Value");
            int value = Convert.ToInt32(node.InnerText);
            combination.Product.Price = value;
            //price
            _productAttributeService.UpdateProductAttributeCombination(combination);
          
            return new NullJsonResult();
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.