I am evaluating Umbraco and would like to know if there are any limitation related to the dynamic creation of unpublished instances of document types.
I'd like to be able to create new unpublished instances of a product document type in code so that as new products enter the market, we have a job which uses the Umbraco api to add them to the Umbraco content database so that when back office is opened the new products appear with the existing products.
A content manager can then modify and publish the new products so they appear on the site. I would think this would be pretty straight forward but have not read of any examples.
I would suggest you create an endpoint in your website, that you can then post the new products to.
The solution here would allow an outside service to post (json) data to yoursite.com/Umbraco/Products/Publish
Example code (just a mockup):
[PluginController("Products")]
public class ProductsController : UmbracoApiController{
[HttpPost]
public void Publish(ProductDto product){
var productListDocumentId = 1234;
var content = Umbraco.UmbracoContext.Application.Services.ContentService;
var p = content.CreateContent(product.Name, productListDocumentId, "ProductDetails");
// p.SetValue for each property....
content.Save(p);
}
}
public class ProductDto {
public string Sku{get;set;}
public string Name{get;set;}
public string Description{get;set;}
public decimal Price{get;set;}
}
Creating instances of Document Types Dynamically
I am evaluating Umbraco and would like to know if there are any limitation related to the dynamic creation of unpublished instances of document types.
I'd like to be able to create new unpublished instances of a product document type in code so that as new products enter the market, we have a job which uses the Umbraco api to add them to the Umbraco content database so that when back office is opened the new products appear with the existing products.
A content manager can then modify and publish the new products so they appear on the site. I would think this would be pretty straight forward but have not read of any examples.
Any assistance would be appreciated.
Hi,
I would suggest you create an endpoint in your website, that you can then post the new products to.
The solution here would allow an outside service to post (json) data to yoursite.com/Umbraco/Products/Publish
Example code (just a mockup):
You would/should also add some security to this.
hth :)
is working on a reply...