Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andriy 4 posts 24 karma points
    Jul 07, 2015 @ 08:51
    Andriy
    0

    Updating uWebShop product via Umbraco Web Api

    Hello,

    I use Umbraco 7.2.6 (also 7.2.5) and uWebShop 2.6.1 I have a problem during updating Product via Umbraco Web API.

    After updating product with Umbraco Management API, content is visible in Umbraco back-office, updated and published. But this product is not available via uWebShop API (for example method Catalog.GetAllProducts()) and also this product is not available via url http://{host}/{category}/{product}, but I can rich it via normal Umbraco url http://{host}/catalog/categories/{category}/{product}. if after updating product via ContentService API, I click "Save and Publish" in back office for this product, it become available via url and uWbShop API.

    Please look at litle bit simplified code for updating content in UmbracoWebApiControiller:

    private void UpdateProduct(ProductModel model)
    {
    IContent product = service.GetById(model.ID);
    //IContnetService service;
    
    service.UnPublish(product);
    product.ParentId = model.ProductCaregories[0];
    product.Name = model.Name;
    product.Language = "en";
    product.SetValue("title" , model.Title);
    product.SetValue("url" , model.Url);
    product.SetValue("sku" , model.SKU);
    product.SetValue("metaDescription" , model.MetaDescription);
    product.SetValue("description" , model.Description);
    product.SetValue("features" , model.Features);
    product.SetValue("shortDescription" , model.ShortDescription);
    product.SetValue("price" , model.GetConvertedPrice());
    product.SetValue("featuredProduct" , model.IsFeatured);
    product.SetValue("topRatedProduct" , model.IsTopRated);
    product.SetValue("bestSellerProduct", model.IsBestSeller);
    product.SetValue("saleProduct" , model.IsSale);
    service.SaveAndPublishWithStatus(product);
    }
    

    I would be happy to get any advice how to fix it. I also published this qurestion here: https://github.com/uWebshop/uWebshop-Releases/issues/52

    Thanks in advance, Andriy

  • Casper Andersen 126 posts 508 karma points
    Jul 17, 2015 @ 07:45
    Casper Andersen
    0

    HI Andriy

    If i understand you correctly. You want to update a product. but you are using the IContent. Shouldent you be using the IProduct instead or is that just me ? Otherwise everything looks good, can ou explain what the problem is ?

  • Andriy 4 posts 24 karma points
    Jul 19, 2015 @ 05:58
    Andriy
    0

    Hi Casper.

    Thanks for your answer. I use IContent because IProduct interface can be used only for read product properties, IProduct has properties with "get" only.

    So my problem is that uWebshop know nothing about product which updated with IContent. I can't use uWebShop API and Url which uWebShop generates for this product.

    Please advice proper solution how to update uWebshop Product properties (predefined and my custom) via code, not in CMS back-office.

    Best regards, Andriy.

  • Casper Andersen 126 posts 508 karma points
    Jul 19, 2015 @ 08:48
    Casper Andersen
    0

    Ok. What i think you might want is this.

    var theOrder = uWebshop.API.Orders.GetCompletedOrder();
    
                if (theOrder != null && theOrder.Status != uWebshop.Common.OrderStatus.Closed)
                {
                    var OrderInfo = uWebshop.Domain.Helpers.OrderHelper.GetOrder(theOrder.UniqueId);
                    OrderInfo.SetStatus(uWebshop.Common.OrderStatus.Closed);
                    OrderInfo.Paid = true;
                    OrderInfo.Save();
                }
    

    Hope this helps and answers your question.

  • Andriy 4 posts 24 karma points
    Jul 19, 2015 @ 16:59
    Andriy
    0

    Hi Casper. No. It is not what I want. I need to change product info, like change picture, title, description, price.

  • Casper Andersen 126 posts 508 karma points
    Aug 04, 2015 @ 06:33
    Casper Andersen
    0

    Hi andriye, i have an idea that might work.

    I was creating an update script the other day, and found out the SetValue is not permitted when updating values, so what you are doing is correct, but the code is a bit wrong. Try and do these changes

    change

    product.SetValue("url" , model.Url);

    into

    product.Properties["url"].Value = model.Url

    Hope this does the trick.

  • Andriy 4 posts 24 karma points
    Aug 04, 2015 @ 08:02
    Andriy
    0

    Hi Casper.

    thanks for good news. I will check this in next couple of days. and let you know about results.

    thanks Andriy

  • Casper Andersen 126 posts 508 karma points
    Aug 28, 2015 @ 14:53
    Casper Andersen
    0

    Did you ever resolve this issue ?

Please Sign in or register to post replies

Write your reply to:

Draft