[6.x] Feature/import - #19612
Draft
i-just wants to merge 198 commits into
Draft
[6.x] Feature/import#19612i-just wants to merge 198 commits into
i-just wants to merge 198 commits into
Conversation
Contributor
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It imports data from a JSON, CSV or XML files into Craft CMS Elements or opted-in Eloquent models.
Core concepts:
Extensibility:
Data Types:
Transformers:
ElementTransformer=> used by default by all elementsEntryTransformer=> default when importing EntriesAssetTransformer=> default when importing AssetsmyPlainTextField, or you can do complex checks to determine what value should be used formyOtherFieldImporters:
ElementImporter— target must be a registered element type whoseisImportable()returns true. Addssite(required) andfieldLayout.ModelImporter— target must implement the marker interfaceImportableModelInterfaceand must not be an element type.RegisterImporterTypesevent.Import configs:
config/craft/import.phpand committed to your repositorymap)matchCriteria)clearableItems)keepMissingNestedElements)Match criteria — three tiers, last wins
matchCriteriakey on the row,[systemHandle => incomingKey].Also looks inside
$data['fields'].additionalMatchCriteria(), already resolved to actual values.Clearable items
An array similar to match criteria. If a field or attribute is
nulland explicitly appliedunset()entirely, so the existing value is left untouched.Import runs:
A run chains ordered steps. Each step consists of Import Config and an optional batch size.
Steps run sequentially, and one bad step doesn’t kill the run. Per-item failures are
logged and skipped, not fatal.
Importing:
artisan craft:import:elementartisan craft:import:modelMaking things importable:
CraftCms\Cms\Component\Concerns\ImportableandCraftCms\Cms\Component\Contracts\ImportableInterfaceisImportable()method,trueby default, that elements can use to opt out (likeAddresselement does); NOTE that Addresses are still importable, just not on their own - always as part of importing into their ownerCraftCms\Cms\Support\Attributes\Importableis used to mark an element's properties as importableCraftCms\Cms\FieldLayout\Contracts\ImportableFieldLayoutElementInterface- used to make field layout elements importableCraftCms\Cms\Field\Contracts\ImportableElementContainerFieldInterface- used by container fields so that they can be imported correctlyCraftCms\Cms\Shared\Contracts\ImportableModelInterfaceto be importable intoPermissions:
There’s a permissions group
import, with the following permissions:viewImportConfigs,saveImportConfigs,deleteImportConfigs,viewImportRuns,saveImportRuns,deleteImportRuns,triggerImportRuns.Related issues
CMS-2390