{"id":22291309,"url":"https://github.com/maestroerror/statamic-magic-import","last_synced_at":"2025-03-25T21:43:06.120Z","repository":{"id":200364213,"uuid":"704416603","full_name":"MaestroError/statamic-magic-import","owner":"MaestroError","description":"Seamless data import experience in statamic control panel","archived":false,"fork":false,"pushed_at":"2023-10-26T13:56:29.000Z","size":218,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"maestro","last_synced_at":"2025-03-02T19:16:37.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaestroError.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-13T08:02:50.000Z","updated_at":"2023-12-17T09:20:57.000Z","dependencies_parsed_at":"2023-10-26T15:05:37.183Z","dependency_job_id":null,"html_url":"https://github.com/MaestroError/statamic-magic-import","commit_stats":null,"previous_names":["maestroerror/statamic-magic-import"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fstatamic-magic-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fstatamic-magic-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fstatamic-magic-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fstatamic-magic-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaestroError","download_url":"https://codeload.github.com/MaestroError/statamic-magic-import/tar.gz/refs/heads/maestro","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245550588,"owners_count":20633871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T17:16:44.058Z","updated_at":"2025-03-25T21:43:06.097Z","avatar_url":"https://github.com/MaestroError.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Statamic Magic Import\n\nyour go-to solution for effortless data imports. With a user-friendly interface and support for **JSON** data formats, importing data into Statamic becomes as easy as a wave of a wand. Experience the magic of hassle-free data management\n\n_This addon can work with JSON files extracted using a [statamic exporter Wordpress plugin](https://github.com/maestroerror/wordpress-to-statamic-exporter)._\n\n## Json import\n\n**JSON file examples:**\n\n[collections.example.json](https://github.com/MaestroError/statamic-magic-import/blob/maestro/collections.example.json)\n\n```js\n{\n  // Defining collections\n  \"collections\": {\n    // Name of new collection (You can add as many collections as you need)\n    \"post\": {\n      // Entrie slug\n      \"/post/top-10-titles\": {\n        // Date of creation (here you can use \"order\" keyword as well)\n        \"date\": \"2023-10-04\",\n        // Fields\n        \"data\": {\n          \"title\": \"Top 10 Titles for example data\",\n          \"content\": \"\u003cdiv\u003eSome HTML content for TinyMCE or Bard fields\u003c/div\u003e\",\n          \"author\": \"admin\",\n          \"featured_image\": \"https://example.com/images/nice-image.webp\", // It will download your image and add to assets\n          \"categories\": [\"category_1\", \"category_2\"], // Create taxonomy and import it in \"Taxonomy terms\" field\n          \"tags\": [\"tag_1\", \"tag_2\", \"tag_3\"] // For \"Taxonomy terms\" field\n        }\n      }\n    }\n  }\n}\n```\n\n[taxonomies.example.json](https://github.com/MaestroError/statamic-magic-import/blob/maestro/taxonomies.example.json)\n\n```js\n{\n  // Defining taxonomies\n  \"taxonomies\": {\n    // Taxonomy name\n    \"categories\": {\n      // Taxonomy terms and titles:\n      \"development\": {\n        \"title\": \"Development\"\n      },\n      \"outsourcing\": {\n        \"title\": \"Outsourcing\"\n      },\n      \"product-design\": {\n        \"title\": \"Product design\"\n      },\n      \"project-management\": {\n        \"title\": \"Project management\"\n      },\n      \"startups\": {\n        \"title\": \"Startups\"\n      },\n      \"tech-news\": {\n        \"title\": \"Tech news\"\n      },\n      \"uncategorized\": {\n        \"title\": \"Uncategorized\"\n      }\n    }\n  }\n}\n\n```\n\n## Features\n\nJson import:\n\n- Create taxonomies and terms\n- Create pages\n- Create collections and entries\n  - includes fields choosing feature for importing in existing collections\n\n_Any meta data key prefixed with an underscore will be ignored._\n\n### Events\n\nThe addon is using the builtin methods for creating and saving content. As such, the normal events are dispatched which you can hook into for additional work according to your setup. That means you can listen on the following events to customize the import:\n\n- `Statamic\\Events\\CollectionCreated`\n- `Statamic\\Events\\CollectionSaved`\n- `Statamic\\Events\\EntrySaving`\n- `Statamic\\Events\\EntryCreated`\n- `Statamic\\Events\\EntrySaved`\n- `Statamic\\Events\\TaxonomySaved`\n- `Statamic\\Events\\TermSaved`\n- `Statamic\\Events\\AssetSaved`\n- `Statamic\\Events\\AssetUploaded`\n\nBy the time you read this there might be others. Consult [the documentation](https://statamic.dev/extending/events#available-events) to learn more.\n\n### Images\n\nAll URLs including image extensions (.png, .jpg, .webp and etc) will be downloaded. Featured images will be downloaded to the \"assets\" container by default (change in config), into a folder called \"{collection_handle}/{entry_slug}\", and saved in a [assets](https://statamic.dev/fieldtypes/assets) field.\n\n## How to Install\n\nYou can search for this addon in the `Tools \u003e Addons` section of the Statamic control panel and click **install**, or run the following command from your project root:\n\n```bash\ncomposer require maestroerror/statamic-magic-import\n```\n\n## How to Use\n\nGo to the `Tools \u003e Magic Import` section and upload the json file.\n\nFor collections, the summary will show you 2 options: creating a new collection or importing in existing one.\n\n![statamic-json-import:creating-new-collection](https://github.com/MaestroError/statamic-magic-import/blob/maestro/resources/img/creating-new-collection.png)\n\nWhen importing in existing collection, you can choose JSON field for each of your collection fields.\n\nEven when creating new collection, there might be the collection with same name. If you choose to import it anyway, the content will be overwritten, but you can (De)Select anything you want (by titles) and click \"Import\".\n\n![statamic-json-import:pages-before-choice](https://github.com/MaestroError/statamic-magic-import/blob/maestro/resources/img/pages-before-choice.png)\n\n![statamic-json-import:collection-after-choice](https://github.com/MaestroError/statamic-magic-import/blob/maestro/resources/img/test-collection-after-choice.png)\n\n_Note: You might get timeout errors if you're importing large datasets and/or many images._\n\n## Config\n\nThe content of the config file looks like this:\n\n```php\n\u003c?php\n\nreturn [\n\n    /*\n     * Enable downloading images. The default is 'true'.\n     */\n    'download_images' =\u003e true,\n\n    /**\n     * The name of the assets container where images should be downloaded.\n     */\n    'assets_container' =\u003e 'assets',\n\n    /*\n     * Whether to skip download of an image if it already exist. The default is 'false'.\n     */\n    'skip_existing_images' =\u003e false,\n\n    /*\n     * Enable image overwriting. When set to false, a new image are created with a timestamp suffix, if the image already exists. The default is 'false'.\n     */\n    'overwrite_images' =\u003e false,\n\n    /*\n     * Set images as Asset object, path or ID\n     * Possible values: path, object, id (If none of them is set 'path' will be used)\n     */\n    'set_images_as' =\u003e \"path\",\n\n    /*\n     * Sets data in same manner as in CP controller, processing via blueprint's fields\n     * Skips field if any error occured and logs the error\n     */\n    'set_data_using_fields' =\u003e false,\n\n    /*\n     * In case if you are updating your images path with some suffix, for example \".webp\"\n     */\n    'image_suffix' =\u003e \"\",\n\n    /*\n     * Filter out meta data keys prefixed with '_'. The default is 'true'.\n     */\n    'exclude_underscore_data' =\u003e true,\n\n];\n\n```\n\nYou can publish configuration file using this command:\n\n`php artisan vendor:publish --tag=statamic-magic-import-config`\n\nYou can publish other asset with the command:\n\n`php artisan vendor:publish --tag=statamic-magic-import`\n\n### To Do\n\n- Using JSON field twice skips the first field (Was using \"title\" from json in \"title\" and \"header\" in collection and collection's \"title\" field was empty)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Fstatamic-magic-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaestroerror%2Fstatamic-magic-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Fstatamic-magic-import/lists"}