feed-me icon indicating copy to clipboard operation
feed-me copied to clipboard

Problems while importing json with matrix data

Open Humbi1992 opened this issue 1 year ago • 5 comments

Description

I'm having problems importing my json file which contains matrix fields.

Steps to reproduce

  1. Create an JSON File with following content:
...
"Benefits": [
    {
        "Shortcut Title": "Shortcut Title",
        "Full Title": "Title",
        "Arguments": {
            "Argument Elements": [
                {
                    "Subtitle": "Subtitle",
                    "Paragraph": "This is a paragraph",
                    "Picture": "image01.png",
                    "Picture Alt Text": "This is Image 01"
                },
                {
                   "Subtitle": "Subtitle",
                    "Paragraph": "This is a paragraph",
                    "Picture": "image02.png",
                    "Picture Alt Text": "This is Image 02"
                }
            ]
        }
    }
],
...
  1. Map:
  • Argument: Subtitlearguments[argument][subtitle] | <Benefits/Arguments/Argument Elements/Subtitle>
  • Argument: Paragrapharguments[argument][paragraph] | <Benefits/Arguments/Argument Elements/Paragraph>
  • Argument: Picturearguments[argument][picture] | <Benefits/Arguments/Argument Elements/Picture>
  • Argument: Picture Alt Textarguments[argument][pictureAltText] | <Benefits/Arguments/Argument Elements/Picture Alt Text>
  1. Execude Feed
  2. It will ignore arguments array

Additional info

  • Craft version: 4.5.5
  • PHP version: 8.0
  • Database driver & version: mysql 5.7.39
  • Plugins & versions: 5.2

Humbi1992 avatar Nov 06 '23 12:11 Humbi1992

Hi, thanks for getting in touch!

Can you please let me know what you have selected as the “Primary Element” on the second screen when setting up a feed (a screenshot would be nice)?

Also, just so that we’re on the same page, is your matrix field called “Arguments” and has a block type called “argument”, and the block has a “subtitle” field (e.g. plain text), “paragraph” field (e.g. plain or rich text) and “picture” Assets field and the volume for it has “picture alt text” field in its field layout - is that correct?

i-just avatar Nov 22 '23 13:11 i-just

Hello @i-just

I collected the following information for you:

My Field Structure:

Benefits (SuperTable) -- Arguments (Matrix) ---- Argument (Matrix Element)

image

As first item i selected products, like in the Screenshot below: image

Humbi1992 avatar Dec 05 '23 08:12 Humbi1992

Thanks for the additional info. After running your feed, do you see any errors in the Logs tab (or in the storage/logs/feedme.log file)?

i-just avatar Dec 06 '23 11:12 i-just

@i-just

Here the feedme.log after the import:

feedme.log

Unfortunately, no real indication of an error or similar.

I tried to reformat the JSON into this:

"Benefits": [
        {
          "Full Title": "",
          "Shortcut Title": "",
          "Arguments": [
            {
              "Subtitle": "",
              "Paragraph": "",
              "Image": ""
            },
         ....

But still doesn't work for me.

Humbi1992 avatar Dec 11 '23 08:12 Humbi1992

Ok, so Feed Me doesn’t support nested Matrix + Super Table (more info can be found, e.g. here: https://github.com/craftcms/feed-me/issues/771). That said, this usually results in a telltale error: Call to a member function getBlockTypeFields() on null - Matrix.php, which is what I’m getting in my tests and why I asked if you saw any after the feed is run.

Can you send the composer.lock, composer.json, database export and a JSON feed file (with just one full element) to [email protected] so I can try to replicate this and dig deeper?

i-just avatar Dec 11 '23 11:12 i-just