2

I'm trying to update existing entries with Sprout Import but when I run the import even though there are no errors the entry's data is not updated. I simplified the JSON script as much as I could and it's still not working:

[
    {
    "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry",
    "related": {
      "relatedResources": {
          "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry",
          "params": {
              "slug": "test-import-child",
              "sectionId": 2
            }
        }
    },
    "settings": {
      "updateElement": {
        "params": {
          "slug": "test-import-parent",
          "sectionId": 2
        }
      }
    }
  }
]

I also tried doing it with just a plain text field instead of a relationship field and still didn't get any change.

[
  {
    "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry",
    "content": {
        "body": "Lorem ipsum dolor sit amet."
    },
    "settings": {
      "updateElement": {
        "params": {
          "slug": "test-import-parent",
          "sectionId": 2
        }
      }
    }
  }
]
2

Reasons why it is not updating

  1. The fields data should be wrapped with fields.
  2. If entry is on other site add siteId on params E.g.

[ { "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry", "content": { "title": "Test Import Parent", "fields": { "body": "Lorem ipsum dolor sit amet." } }, "settings": { "updateElement": { "params": { "slug": "test-import-parent", "sectionId": 2, "siteId": 1 } } } } ]

2

I needed to put my "related" array inside a "content" array:

[

  {
    "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry",
    "content": {
      "related": {
        "relatedResources": {
            "@model": "barrelstrength\\sproutbase\\app\\import\\importers\\elements\\Entry",
            "params": {
                "slug": "test-import-child",
                "sectionId": 2,
                "siteId": 1
              }
          }
      }
    },
    "settings": {
      "updateElement": {
        "params": {
          "slug": "test-import-parent",
          "sectionId": 2,
          "siteId": 1
        }
      }
    }
  }

]

I also added the siteId parameter as a matter of good practice but it's not strictly necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.