OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.23k stars 2.34k forks source link

Improvement idea: Import custom content #7865

Open MikeKry opened 3 years ago

MikeKry commented 3 years ago

Hi, I believe that I have searched every bit of documentation of OC but did not found a way to import custom data from excel or something.

Just got idea which could help devs to import their own content and it should not cost too much time to include in OC..

Idea: Use orchard import / export and just modify "ContentStep" to allow inserting, if there is no VersionId and ContentItemId provided and use some ImportContentItemId to avoid duplicates. Then users could use their own way to transform their datasource to json and import these documents.

This could be in theory doable even now, but there is no easy way to generate unique contentitemid from some custom dataset.

What do you think about that?

fpionnmedia commented 3 years ago

Hi, I have the exact same issue and haven't found any way to import custom data.

I'm rebuilding a client website and I'm upgrading from an old .NET Framework CMS to a newer CMS (Orchard Core is my preferred candidate for now). I can control the data format (CSV, Excel, JSON, etc.) and I'd like to know if there was a way to import my contents in Orchard Core. There are more than 1,000+ contents in the website and entering them manually is out-of-the-question.

Thanks!

Skrypt commented 3 years ago

I will be working on something today for that. At least I think we should be able to import simple content items from an Excel file. Basically it would convert the Excel to JSON so that it can be imported with the Import/Export feature. But I need to try different things first.

MikeKry commented 3 years ago

Just a thought: I have ended with implementing my own importer by using code that is already present in OrchardCore.Content.Controllers.ApiController.

Basically what it does = loads csv file, maps fields from csv into json structured content item, calls create/update copied from that api controller.

maybe this could be the way to create some general excel/csv/json importer

Skrypt commented 3 years ago

I would generally tend toward using the Import feature we already have which can handle a lot. I don't know about the ApiController. We do bulk insert/updates with the import feature but not with the ApiController. So the logic and whatnot is already working with the Import feature.

Anything that you could share though would be great. πŸ˜„

The code part that does "maps fields from csv into json structured content item" I'm interested in πŸ˜‰

fpionnmedia commented 3 years ago

@Skrypt Do you have a link on the Import feature? I don't seem the find it in the documentation, nor I do see it in the CMS... (I'm using the master branch, I'll take a look at the dev branch later).

Skrypt commented 3 years ago

OrchardCore.Deployment

hyzx86 commented 3 years ago

I have a same issue too.. https://github.com/OrchardCMS/OrchardCore/issues/9616

hyzx86 commented 3 years ago

@Skrypt so , we can follow your demo to implement a Relational Database import feature 😊

Skrypt commented 3 years ago

You guys can take a look at this project :

https://github.com/dalenewman/Transformalize/blob/master/README.md

hyzx86 commented 3 years ago

Great proposal and great project. Thanks for sharing @Skrypt

Skrypt commented 2 years ago

I'm pinging this issue back as I'm curious to know if Nmedia developped a solution for this. @fpionnmedia maybe you should ask Nicolas HΓ©bert about this as I think he's the DB guy. As for myself, I did use the ContentManager directly to import data in Orchard Core. But, doing this again I would probably opt to generate recipe.json files to import the data. But that's not the entire answer.

Of course, if you have a relational database that needs to be built in some specific way you need to build also IndexingProviders before importing the data to fill up these tables. Or you can use the tables as is too.

Also, there is always the option to consume the data from the GraphQL API so that you don't need to change the database data at all. You compose SQL Queries and expose the data with a Schema and then you can consume the database custom tables.

Here, the idea is that if you need relational tables you need to use IndexingProviders to map the data. Nothing prevents you in Orchard Core to use relation between tables but you need to define them through a combination of migrations, recipes and else.

Also, nothing prevents you from using Dapper or EF directly in some custom modules that would be coded with a different approach.

Also building an API to export the data as JSON from Altitude would not be a bad idea.

πŸŽ…πŸΌ ...