• Resolved expirator

    (@expirator)


    During the Drag&Drop stage of the import I’m adding fields like this:

    {ID[1]}

    which are part of xpath /item2

    How can I get the value of something that is the xpath that is a level above /item2? It’s not the direct parent, but it’s at the parent level.

    I’d imagine it would be something like {..parent[1]} but I can’t seem to figure anything out?

    Basically my json looks like:

    {
            "Count": 1,
            "Message": "Results returned successfully",
            "Company": "XYZ",
            "Product": [
                {
                    "ID": 60,
                    "Name": "TRAILERS",
                    "NName": "TRAILERS"
                },

    And I’d like to import many Product sets but I need the Company attached to each.

    Would appreciate any thoughts or ideas.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Aakash

    (@aakash8)

    See if this syntax helps
    https://stackoverflow.com/a/28237764

    Thread Starter expirator

    (@expirator)

    I saw that same post, but I can’t seem to get it to work! The curly brace syntax of WPALLImport doesn’t seem to respond to xpath what it comes to the import (step 3), only to the json/xml targeting in step 3.

    Have you had any luck with targeting a parent when importing custom fields?

    Plugin Author WP All Import

    (@wpallimport)

    Hey @expirator,

    If you choose “Product” as the XPath element to be imported on Step 2, I’m afraid it’s not possible to access data above that when building the import template using our built-in options.

    That said, it is possible to do it with custom PHP and our API, but it can get a little complex. Here’s an example that you can modify to work with your data file: https://www.wpallimport.com/documentation/code-snippets/#access-data-above-element-chosen-on-step-2. Note that WP All Import converts all data files to XML, even if they’re uploaded as JSON/CSV/XLS/XLSX.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Get Parent During Import’ is closed to new replies.