Merging/querying external data to display with Umbraco content
I'm new to Umbraco. I need to query for and get some external data (from a database) and have it available alongside the values coming from the Umbraco properties.
For example, I have a Product document type. A product has data setup within Umbraco, but I need to query an external data source which is updated daily with some other values and also have it available along with the data coming from Umbraco. I can associate them based on the Product ID, which is available as a property on the Product from Umbraco (@CurrentPage.productId = "234655").
How would I go about doing this? Also, is it best to have the other data in the same database as Umbraco or in a separate database?
There are a few different ways of doing this - if you're mixing a lot of content from an external system (say a product DB) with Umbraco content then I'd suggest a Custom Controller.
In your controller call / query an external data source (via a "helper" class, be it an external DB, API or just some custom tables stored to the Umbraco DB) and return a model with your Umbraco content and product data mixed in.
Take a look at hybrid framework package (https://our.umbraco.org/projects/developer-tools/hybrid-framework/) and route hijacking so see how to create new model and enrich with umbraco and custom data. Also with regards to external datatables i would recommend separate db that way when you upgrade you do not have to worry about that table.
We have in the past had data in same db and then had to content freeze on those tables when doing upgrade. This way separate db you do not have to worry about it.
Merging/querying external data to display with Umbraco content
I'm new to Umbraco. I need to query for and get some external data (from a database) and have it available alongside the values coming from the Umbraco properties.
For example, I have a Product document type. A product has data setup within Umbraco, but I need to query an external data source which is updated daily with some other values and also have it available along with the data coming from Umbraco. I can associate them based on the Product ID, which is available as a property on the Product from Umbraco (@CurrentPage.productId = "234655").
How would I go about doing this? Also, is it best to have the other data in the same database as Umbraco or in a separate database?
There are a few different ways of doing this - if you're mixing a lot of content from an external system (say a product DB) with Umbraco content then I'd suggest a Custom Controller.
https://our.umbraco.org/documentation/reference/routing/custom-controllers
In your controller call / query an external data source (via a "helper" class, be it an external DB, API or just some custom tables stored to the Umbraco DB) and return a model with your Umbraco content and product data mixed in.
Hope that helps
Steve
Matt,
Take a look at hybrid framework package (https://our.umbraco.org/projects/developer-tools/hybrid-framework/) and route hijacking so see how to create new model and enrich with umbraco and custom data. Also with regards to external datatables i would recommend separate db that way when you upgrade you do not have to worry about that table.
We have in the past had data in same db and then had to content freeze on those tables when doing upgrade. This way separate db you do not have to worry about it.
is working on a reply...