• Resolved jaak69

    (@jaak69)


    Hello,
    I didn’t find from documentation is it possible to import mapping rules from csv file.
    The main CSV import file has field “countryID” which is number and I have another CSV
    file there “countryID” mapped with actual country name (132 records). I can manually insert them as mapping rules, but is it possible to automate that and import all from csv file.

    Jaak

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Let me know if you find a solution. Have the same issue.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @jaak69

    It sounds like you could use a PHP function or our API to translate the values.

    Can you provide more details on where you’re importing the “countryID” data? Is it a custom field, a taxonomy, or something else? If you have some data examples that would be helpful as well.

    Thread Starter jaak69

    (@jaak69)

    Hello,
    This is a custom field:
    It looks in import csv:
    country_id
    0
    53
    0
    17
    0
    0

    And the mapping csv:
    country_id
    1 Eesti EE
    3 Venemaa RU
    4 Soome FI
    11 Leedu LT
    12 L?ti LV
    13 Poola PL
    14 Hispaania ES
    15 Itaalia IT
    16 Türgi TR
    17 Hiina CN
    18 Andorra AD
    19 Araabia ühendemiraadid AE
    20 Albaania AL
    21 Armeenia AM
    ….
    etc.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @jaak69

    Thank you for the example. Unfortunately, there are currently no built-in options to import mapping rules like this, but you could do it with your own custom solution.

    You should convert the mapping CSV to a PHP array (see str_getcsv), then write a PHP function for the mapping rules. Example:

    // Map function
    function my_map_field( $data ) {
        // Replace this array with the data from your CSV file
        $map = array(
                'Translate This' => 'To This New Value',
                'And this' => 'To this',
                'Add as many' => 'Rules',
                'As you need' => 'In this array',
            );
    
        return isset( $map[ $data ] ) ? $map[ $data ] : $data;
    }

    You can use that function in the import template as described here: https://www.wpallimport.com/documentation/developers/execute-php/.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Mapping rules import from CSV’ is closed to new replies.