• Resolved giallo1993

    (@giallo1993)


    I have WP All Import Pro!
    Ik want to replace a tekst in 3 of the field in the downloaded XML.

    I created a PHP entry in the import-definition like
    <?php
    [str_replace(“Dames “, “”, fields[1]/CategorieOmschrijving[1])]
    [str_replace(“Dames “, “”, fields[1]/ShopOmschrijving[1])]
    [str_replace(“Dames “, “”, fields[1]/KenmerkadviseurOmschrijving[1])]
    ?>

    For some kind of reason this doesn’t work

    Example: fieldvalue ‘Dames Schoenen’ should be ‘Schoenen’
    I don’t want to use ‘mapping’ because there are 100+ possible value’s

    Please help

    https://www.ads-software.com/plugins/wp-all-import/

Viewing 1 replies (of 1 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Where are you entering this? Why have you included php open/close tags?

    If you want to write a custom function to create your own mapping rules, you should:

    1) Write a custom function that passes your category data through all of your str_replace filters

    2) Pass all of your categories through that one function.

    Using the above example, your function would be:

    function no_dames( $str ) {
    
        $str = str_replace( "Dames ", "", $str );
        return $str;
    
    }

    If you wanted to filter out something else as well, you’d modify your function like so:

    function no_dames( $str ) {
    
        $str = str_replace( "Dames ", "", $str );
        $str = str_replace( "something else ", "", $str );
        return $str;
    
    }

    Then to import your category you’d enter [no_dames({fields[1]/KenmerkadviseurOmschrijving[1]})] into the category import section.

    Note that the code above is untested and for example purposes, and that the XML node being passed into the no_dames function may not be correct. You can read more about custom functions here: https://www.wpallimport.com/documentation/developers/execute-php/

    If you need any additional help with this please submit a support request: https://www.wpallimport.com/support/

Viewing 1 replies (of 1 total)
  • The topic ‘PHP replace command’ is closed to new replies.