Skip to content

Commit

Permalink
Merge branch 'release/5.1.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Apr 17, 2023
2 parents ef15885 + e351698 commit 540c335
Show file tree
Hide file tree
Showing 43 changed files with 511 additions and 219 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release Notes for Feed Me

## 5.1.2 - 2023-04-17

- Added support for importing into CKEditor as an inner element field.
- Fixed a PHP error that could occur when saving a feed using an Asset element type with no volume selected.
- Fixed a PHP error that could occur when importing a feed that has `setEmptyValues` set to off on the feed. ([#1269](https://github.com/craftcms/feed-me/issues/1269))
- Fixed several bugs related to empty and non-existent feed values and the “Set Empty Values” feed setting. ([#1271](https://github.com/craftcms/feed-me/pull/1271))
- Fixed a bug where that prevented importing data as Commerce Variants. ([#464](https://github.com/craftcms/feed-me/issues/464), [#1168](https://github.com/craftcms/feed-me/issues/1168))
- Fixed a bug were you could not import into Redactor as an inner element field.
- Fixed a bug where mapping into fields that support inner elements that were inside of Matrix, content from the first element was used to populate all other elements. ([#1227](https://github.com/craftcms/feed-me/issues/1227), [#1278](https://github.com/craftcms/feed-me/pull/1278))
- Fixed a bug where importing a user with an empty user photo in the feed, would assign an incorrect photo for the user. ([#582](https://github.com/craftcms/feed-me/issues/582), [#1283](https://github.com/craftcms/feed-me/pull/1283))
- Fixed a bug where importing into Matrix sub fields could use incorrect data when “Use default value” was selected for the field. ([#674](https://github.com/craftcms/feed-me/issues/674), [#1282](https://github.com/craftcms/feed-me/pull/1282))
- Removed the “Collapsed” checkbox from Matrix feed mapping screens. ([#709](https://github.com/craftcms/feed-me/issues/709), [#1284](https://github.com/craftcms/feed-me/pull/1284))
- Fixed an XSS vulnerability.

## 5.1.1.1 - 2023-02-24

- Fixed a PHP error that could occur when importing into some 3rd party fields. ([#1264](https://github.com/craftcms/feed-me/issues/1264), [#1265](https://github.com/craftcms/feed-me/pull/1265))
Expand Down Expand Up @@ -74,6 +88,14 @@
### Removed
- Removed built-in support for the Verbb Comments plugin, which provides its own Feed Me driver.

## 4.6.1.1 - 2023-03-24

- Fixed a PHP error that could occur when importing into some 3rd party fields. ([#1264](https://github.com/craftcms/feed-me/issues/1264), [#1265](https://github.com/craftcms/feed-me/pull/1265))

## 4.6.1 - 2023-03-20

- Fixed a JavaScript error that would occur on case-sensitive filesystems when using Feed Me. ([#1260](https://github.com/craftcms/feed-me/pull/1260), [#1257](https://github.com/craftcms/feed-me/issues/1257), [#1258](https://github.com/craftcms/feed-me/issues/1258), [#1259](https://github.com/craftcms/feed-me/issues/1259))

## 4.6.0 - 2023-03-16

- Added the “Set Empty Values” feed setting, which determines whether empty values in the feed should be respected or ignored. ([#1228](https://github.com/craftcms/feed-me/pull/1228), [#797](https://github.com/craftcms/feed-me/issues/797), [#723](https://github.com/craftcms/feed-me/issues/723), [#854](https://github.com/craftcms/feed-me/issues/854), [#680](https://github.com/craftcms/feed-me/issues/680))
Expand Down
18 changes: 11 additions & 7 deletions docs/content-mapping/element-types.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Element Types

Selecting which Element Type to import into is the first step in using Feed Me. As each Element Type is different, you'll have different attributes to map depending on which you'd like to create.
Selecting which element type your import targets is the first step in using Feed Me. As each element type is different, the presented [mapping](../feature-tour/field-mapping.md) options will be unique.

## Built-in Importers

Feed Me can import content for the following element types out of the box:
The following element types are supported by Feed Me, out of the box:

- **Core element types:** entries, categories, tags, assets, and users
- **[Craft Commerce](https://plugins.craftcms.com/commerce):** products
- **[Digital Products](https://plugins.craftcms.com/digital-products):** digital products
- **[Calendar by Solspace](https://plugins.craftcms.com/calendar):** events
- **[Verbb Comments](https://plugins.craftcms.com/comments):** comments
- **[Core element types](https://craftcms.com/docs/4.x/elements.html):** Assets, categories, entries, tags, and users;
- **[Craft Commerce](https://plugins.craftcms.com/commerce):** Products and variants;
- **[Digital Products](https://plugins.craftcms.com/digital-products):** Digital products;
- **[Calendar by Solspace](https://plugins.craftcms.com/calendar):** Events;
- **[Verbb Comments](https://plugins.craftcms.com/comments):** Comments;

::: tip
Plugins can add support for their own [custom element types](../developers/element-types.md), as well.
:::
58 changes: 4 additions & 54 deletions docs/content-mapping/field-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Field Types

Feed Me supports all native [Craft Fields](https://craftcms.com/docs/fields), and even some third-party ones.
Feed Me supports all native [Craft Fields](https://craftcms.com/docs/4.x/fields.html), and even some third-party ones.

### Assets

Expand Down Expand Up @@ -190,6 +190,7 @@ Accepts a single value. You must provide the Value of the option to select, not
:::

### Entries

Accepts single or multiple values.

#### Additional Options
Expand Down Expand Up @@ -343,43 +344,6 @@ Accepts a single value.
```
:::

### Position Select

Accepts a single or multiple values. Should provide from the below options:

- `left`
- `center`
- `right`
- `full`
- `drop-left`
- `drop-right`

:::code
```xml
<Position>right</Position>

// Or
<Positions>
<Position>left</Position>
<Position>right</Position>
</Positions>
```

```json
{
"Position": "right"
}

// Or
{
"Positions": [
"left",
"right"
]
}
```
:::

### Radio Buttons

Accepts a single value. You must provide the Value of the option to select, not the Label.
Expand All @@ -396,22 +360,6 @@ Accepts a single value. You must provide the Value of the option to select, not
```
:::

### Rich Text

Accepts a single value. Be sure to escape your content properly if it contains HTML.

:::code
```xml
<RichText><![CDATA[<p>Lorem ipsum dolor sit amet.</p>]]></RichText>
```

```json
{
"RichText": "<p>Lorem ipsum dolor sit amet.</p>"
}
```
:::

### Table

Each Table field row has multiple columns, so you map each field value to a column, rather than the entire Table field. You also group your columns into rows, as shown below.
Expand Down Expand Up @@ -577,3 +525,5 @@ Depending on what data your feed contains, you'll need to select the appropriate
## Inner Element Fields

As each Element (Assets, Categories, Entries, Tags, Users) can have custom fields themselves, Feed Me gives you the chance to map to those fields as well. They'll appear under any row when mapping to an Element field.

See the introduction to field mapping for more information on setting up nested fields.
29 changes: 19 additions & 10 deletions docs/feature-tour/creating-your-feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,24 @@ If you have a multi-site Craft installation, you'll have an additional “Target

### Import Strategy

The Import Strategy tells Feed Me how to act when (or if) it comes across elements that are similar to what you're importing. If you've imported your content once, there will very likely be elements with the same title or content as what you're trying to import.
The **Import Strategy** tells Feed Me how to act when (or if) it comes across elements that are similar to what youre importing. If youve imported your content once, there will very likely be elements with the same title or content as what you're trying to import.

For example - you have an existing entry called "About Us", but you also have an item in your feed with exactly the same title. You should tell Feed Me what to do when it comes to processing this entry in your feed. Do you want to update that same entry, or add a new one?
::: tip
The actual matching behavior is determined by a [unique identifier](field-mapping.md#unique-identifiers), which you’ll configure in a moment.
:::

For example: you have an existing entry called “About Us,” but you also have an item in your feed with exactly the same title. You should tell Feed Me what to do when it comes to processing this entry in your feed. Do you want to update that same entry, or add a new one?

You can select from any combination of the following:

Attribute | Description
--- | ---
`Create new elements` | Adds new elements if they do not already exist. If an element does exist, it simply skips over it, leaving it unchanged.
`Update existing elements` | Updates elements that match the Unique Identifier (next step). If no existing element to update, it won't create it unless you select `Create new elements`.
`Disable missing elements` | Disables elements that are not updated by this feed.
`Disable missing elements in the target site` | Disables elements that are not updated by this feed, but only in the feed’s [target site](#target-site).
`Delete missing elements` | Deletes elements that are not updated by this feed. **Be careful when deleting**.
`Update search indexes` | Whether search indexes should be updated.
**Create new elements** | Adds new elements if they do not already exist (as determined by a _unique identifier_). If an element _does_ exist, it will only be updated if **Update existing elements** is enabled.
**Update existing elements** | Updates elements that match the _unique identifier_. If no existing element matches, one will be only be created if **Create new elements** is also enabled.
**Disable missing elements** | Disables elements that are not updated by this feed.
**Disable missing elements in the target site** | Disables elements that are not updated by this feed, but only in the feed’s [target site](#target-site).
**Delete missing elements** | Deletes elements that are not updated by this feed. **Be careful when deleting**.
**Update search indexes** | Whether search indexes should be updated.

### Passkey

Expand All @@ -61,7 +65,12 @@ A generated, unique string to increase security against imports being run inadve

Enable a backup of your database to be taken on each import. Please note the [performance implications](../troubleshooting.md#performance) when switching this on.

* * *
### Set Empty Values

Click on the _Save & Continue_ button to be taken to the [Primary Element](primary-element.md) screen, or press _Save_ to continue editing this screen.
When enabled, empty values in a feed item are considered valid and will clear the corresponding fields when your [Import Strategy](#import-strategy) includes _update existing elements_. When disabled, empty values are ignored or treated as unchanged.

Keys omitted from a feed item are not considered “empty” and will not clear values on existing entries.

* * *

Click **Save & Continue** to be taken to the [Primary Element](primary-element.md) screen, or **Save** to continue making changes on this screen.
95 changes: 82 additions & 13 deletions docs/feature-tour/field-mapping.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,102 @@
# Field Mapping

Field Mapping provides an interface to match items in your feed to fields in Craft. Depending on the element you’ve selected to import into will determine what fields you have available to map against.
Now that you’ve told Feed Me where your data comes from, it’s time to define how individual items in the feed map to new or existing elements in Craft.

While the specifics will vary widely depending on your content model (and the structure of the incoming data), the same pattern applies to most map configuration:

1. Find the _target_ field in the **Field** column;
1. Choose a _source_ for that field’s data from the menu in its row’s **Feed Element** column;
1. Customize options for the type of data being imported;
1. (Optional) Set a static or dynamic [default value](#default-values);

## Native Fields

The native fields you have available to map against depend on the element type you’ve selected as the target for the import—for example, entries support a **Title**, **Slug**, **Parent**, **Post Date**, **Expiry Date**, **Status**, and **Author** in addition to the [custom fields](#custom-fields) attached via its field layout.

::: tip
Native fields have similar options to [custom fields](#custom-fields), so we’ll only cover the novel ones, in this section.
:::

### Element IDs

You can map data in your feed to the Element ID, which is useful if you know for certain an element you want to update. This can be when updating for content in other locales, or bulk-updating existing items.
You can map data in your feed to the element ID, which is useful if you are certain which element you want a given feed item to update. This can be when updating for content in other locales, or bulk-updating existing items.

::: danger
Do not use this when importing new data. If you’re importing your content from another system (ExpressionEngine, WordPress, etc.), your new content will almost assuredly not have the same ID between systems. This is how Craft’s Elements work, and if you specify the wrong Element ID to update, you could be updating the wrong content altogether (an Asset when you meant to update an Entry).
Do not use this when importing “new” data! Content from another system (ExpressionEngine, WordPress, etc.) will _not_ have the same IDs as their corresponding elements in Craft, by virtue of how records are created in the database. If you specify the _wrong_ element ID (deliberately or coincidentally), you run the risk of updating completely unrelated content (i.e. an asset when you meant to update an entry).

There are only two situations in which setting IDs is recommended:
- When re-importing data that was exported from Craft, then modified;
- Importing or synchronizing data from external systems that already track Craft element IDs;

In most cases, incoming data should be matched based on a different [unique identifier](#unique-identifiers).
:::

### Unique Identifiers
## Custom Fields

It's important to select a Unique Identifier for your feed to assist with the Import Strategy you’ve chosen. When comparing against existing entries, it will compare the fields you select here with the data in your feed. Most commonly, this would be the Title for the element, but is also a good idea to be against a unique ID.
Like native fields, each custom field type’s configuration options depend on what kind of data it stores.

::: danger
Updating content based on a Unique Identifier will not work for content stored in Matrix and other nested, Matrix-like fields such as Super Table and Neo.
### Scalar Data

Text, numbers, booleans, and other basic data types require no additional configuration. Color, dropdown, email, lightswitch, money, radio, and URL fields all use “scalar” values.

### Dates

Feed Me can parse [most date formats](https://www.php.net/manual/en/function.strtotime.php), but to handle cases where it may be ambiguous (i.e. `01-02-2023`), you can lock the mapping to a specific pattern.

### Relational Fields

When setting up related content through an assets, categories, entries, tags, or users field, you will be asked how Feed Me should locate the referenced element(s).

For example, if you were importing a list of AKC winners that contained a `breed` property with values like `Dachshund` or `Greyhound`, you might tell Feed Me to look up existing _Breed_ entries by their **Title**, and to **Create entries if they do not exist**. The same holds true for other element types and their corresponding relational field types.

#### Nested Fields

When importing relational data, you have an opportunity to map values onto those elements’ fields, as well. Enable **Element fields (x)** to expand controls for those nested fields.

::: warning
Keep in mind that nested field values will be applied uniformly to all relations.
:::

### Default Value
### Matrix

See the [Importing into Matrix](../guides/importing-into-matrix.md) guide to learn more about this special field type.

### Plugin Fields

Feed Me comes with support for the following plugin-provided field types:

You can set a default value for any field, and depending on the field, this may be in the form of a text field or a select field. You can also provide a default value using shorthand Twig (if you enable `parseTwig` in your [Configuration](../get-started/configuration.md)), referring to other fields in the element you're importing.
Field Type | Developer
--- | ---
[Calendar Events](https://plugins.craftcms.com/calendar) | Solspace
[Commerce Products](https://plugins.craftcms.com/commerce) | Pixel & Tonic
[Commerce Variants](https://plugins.craftcms.com/commerce) | Pixel & Tonic
[Entries Subset](https://plugins.craftcms.com/entriessubset) | Nathaniel Hammond
[Google Maps](https://plugins.craftcms.com/google-maps) | Double Secret Agency
[Linkit](https://plugins.craftcms.com/linkit) | Pressed Digital
[Simplemap](https://plugins.craftcms.com/simplemap) | Ether Creative
[Super Table](https://plugins.craftcms.com/supertable) | Verbb
[Typed Link](https://plugins.craftcms.com/typedlinkfield) | Sebastian Lenz

::: tip
Make sure you select `Use default value` in the “Feed Element” dropdown, otherwise it won’t work!
Other fields that store simple text values (like [Redactor](https://plugins.craftcms.com/redactor)) will work automatically.
:::

![Feedme Mapping](../screenshots/feedme-mapping.png)
## Default Values

The screenshot above shows three columns. The first is for your Craft field, the second is a dropdown for selecting the node in your feed, and the third is for setting the default value.
When the source for a native or custom field is set to “Use default value,” you may provide a value in the third column that will supersede any default value defined by the field itself. If `parseTwig` is enabled in your [Configuration](../get-started/configuration.md), textual fields are treated as Twig “object templates,” and have access to other fields on the element you're importing:

You’ll notice the `Assets` field has a Plain Text row in slight grey below it. This represents a field on the element itself.
```txt
{title} was last imported on {{ now | date }}
```

## Unique Identifiers

It's important to select a **unique identifier** for your feed to assist with the **Import Strategy** you’ve chosen. When comparing against existing entries, it will compare the fields you select here with the data in your feed. In addition to the element’s native fields (like title, slug, status, or ID), you may use custom field values for matching.

::: warning
There are _some_ limitations to the matching engine, though—it will not work for content stored in Matrix and other nested, Matrix-like fields such as Super Table and Neo which can’t be easily or reliably serialized.
:::

::: danger
If data that is used as part of a unique identifier is altered between imports by a user (or any other means—including a different import), Feed Me may not be able to match it again! When combined with the **Delete missing elements** [import strategy](creating-your-feed.md#import-strategy), this can result in inadvertent data loss.
:::
Binary file modified docs/screenshots/feedme-logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/feedme-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 540c335

Please sign in to comment.