uWebshop / -INACTIVE-uWebshop-Core

[INACTIVE] The source of the uWebshop E-Commerce module for Umbraco
MIT License
12 stars 14 forks source link

Updating uWebShop product via Umbraco Web Api #52

Open Sharpsturdy opened 9 years ago

Sharpsturdy commented 9 years ago

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.

Thanks in advance, Andriy

Sharpsturdy commented 9 years ago

Hello, Do you need more information from me? or any other way i can help you find out what is the problem? Or may be you can advice how to update products programatically without CMS back-office?

ArnoldV commented 9 years ago

@Sharpsturdy I guess that Umbraco does not trigger all events when using that code.

You could use code in our after publish event: https://github.com/uWebshop/uWebshop-Releases/blob/develop/Umbraco/uWebshop.Umbraco/ApplicationEventHandler.cs#L737

(the ResetAll probably)

Sharpsturdy commented 9 years ago

Thanks, I will check your solution in neareast future.