• Resolved brandsforless

    (@brandsforless)


    Hello,
    your plugin is awesome.
    Many months ago i asked about a php function to translate my product xml feed from English in my languange -Greeks.
    You sens me the bellow function which work like a charm.
    function my_translate_data( $data ) {
    $map = array(
    ‘Translate this’ => ‘To this’,
    ‘Add as many mapping rules’ => ‘As needed’,
    ‘In this’ => ‘Array’
    );
    return ( array_key_exists( $data, $map ) ) ? $map[ $data ] : $data;
    }

    The problem is that the use of the function is also modify and the permalink in my languange. With other words i need to translate in Greeks the product title but leave the permalink slug in English.

    Is this possible and if yes does it need to add an extra code in the php function?

    Thank you in advance.

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

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

    (@wpallimport)

    Hi @brandsforless

    With other words i need to translate in Greeks the product title but leave the permalink slug in English.

    In that case you could put the English slug in the Other Post Options -> Post Slug field inside the import template: https://d.pr/i/1JxyqH. I’m assuming this would be your product title element without the function.

    Thread Starter brandsforless

    (@brandsforless)

    Thank you for your quick response.
    I do many trials with the field Post Slug with no effort.
    My item product in the xml feed is like this:

    <product id=”107541″>
    <name>Skirt model 107541 IVON</name>
    <brand>IVON</brand>
    <category_path>/WOMEN/Women`s Clothing/Skirts</category_path>
    <category id=”125″>Skirts</category>
    <color>black</color>
    <type>Skirt</type>
    <images></images>
    <price>23.9</price>
    <description></description>
    <options>
    <option id=”M668398″>
    <option_name>36</option_name>
    <STOCK>5</STOCK>
    <avaible_in>7</avaible_in>
    </option>
    <option id=”M668399″></option>
    <option id=”M668400″></option>
    <option id=”M668401″></option>
    <option id=”M668402″></option>
    </options>
    </product>

    What input i have to use in Post Slug for the <name> field during the import process to be translated in Greece but the permalink keep in English?

    Thank you

    Plugin Author WP All Import

    (@wpallimport)

    Hi @brandsforless

    What input i have to use in Post Slug for the <name> field during the import process to be translated in Greece but the permalink keep in English?

    In the Title put:

    [my_translate_data({name[1]})]

    See: https://d.pr/i/vR9NYg.

    Then, in the Post Slug, put:

    {name[1]}

    See: https://d.pr/i/InO77g.

    If you need further assistance with this please open a ticket at https://www.wpallimport.com/support/ so we can see your import settings & data.

    Thread Starter brandsforless

    (@brandsforless)

    Hello,
    everything works like charms now.
    My function.php is ok.
    One more question please.
    Can i use seperate functions file for each import?
    My only one function.php is the same for all my imports. But in some imports i have to translate one word different way for each one.
    For example shirt translation is right for women tops but is not right for swimsuits and for tankini shist product.
    It will be very usefull to use different function.php for each import.
    Thanks

    Plugin Author WP All Import

    (@wpallimport)

    Hi @brandsforless

    You can’t have multiple function files for our Function Editor, but you can create different functions for each import in the same file. Or, if you’d rather organize your code better, you could not use our Function Editor at all and move your code to a plugin like Code Snippets: https://www.ads-software.com/plugins/code-snippets/.

    Thread Starter brandsforless

    (@brandsforless)

    Thank you again for your response.
    Actually i do not like the idea to use another plugin. I prefer to have one function.php file from your Function Editor.
    As you realize i am not a developer and run my e-commerce site alone.
    For sure i need to add a code for make the different function for each import.
    I think it need to add an add_filter command or something like this.
    Can you please suggest something to me for the following function?
    <?php
    function my_translate_data( $data ) {
    $map = array(
    ‘Lenght’ => ‘Μ?κο?’,
    ‘Total’ => ”,
    ‘Size’ => ‘Μ?γεθο?’,
    ‘Hips’ => ‘Γοφο?’,
    ‘Width’ => ”,
    ‘Chest’ => ‘Μπο?στο’,
    ‘Bust’ => ‘Μπο?στο’,
    ‘Waist’ => ‘Μ?ση’,
    ‘Under’ => ‘Κ?τω απ? ‘,
    ‘Bottom’ => ‘Κ?τω σ?νολο ‘,
    );
    }
    ?>
    return str_ireplace( array_keys( $map ), $map, $data );
    Don’t care of course for the Greeks translations.

    And again excuse me to be so efortic to you.

    Thank you.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @brandsforless

    For sure i need to add a code for make the different function for each import.

    My suggestion would be to add a second argument to your function so that you can pass the import name (or translation name) to it. For example, the function could look like this: https://paste.ee/p/G3GAC. Then, in the import template, you can decide which translations to use, e.g.:

    [my_translate_data( {data[1]} )] // this uses default translations
    [my_translate_data( {data[1]}, "swimsuits" )] // this uses swimsuits translations
    [my_translate_data( {data[1]}, "shirts" )] // this uses shirts translations
    Plugin Author WP All Import

    (@wpallimport)

    @brandsforless I’m marking this as resolved. Let us know if you have more questions regarding the same issue.

    Thread Starter brandsforless

    (@brandsforless)

    Hi,
    everything works fine. I am very excited about your fast and reliable halp.
    Keep going.
    Thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘XML feed mapping’ is closed to new replies.