• Resolved ilyapokrov

    (@ilyapokrov)


    Please help me with a solution to one question. How can I write all fields with the same “name” to attributes ? I will explain – for example, there is a dress, it has three sizes. The other dress has five sizes. In the file, they have “param” and “name”. If I specify {param[1]}, {param[2]}, {param[3]}, then everything will go wrong when the next product has only one size. I tried to explain clearly)) Did you understand me?

    https://look-catalog.ru/wp-content/uploads/2020/11/Screenshot_1.jpg

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ilyapokrov

    (@ilyapokrov)

    Just in case, I will try to specify: in the end, all the values specified in the file should be written to this attribute. I can’t do this using the / symbol, because I don’t know the exact number of values for this parameter.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @ilyapokrov,

    First, add this code in your child themes functions.php file or in a plugin like Code Snippets:

    function wpai_is_xml_preprocess_enabled( $is_enabled ) {
    	return false;
    }
    add_filter( 'is_xml_preprocess_enabled', 'wpai_is_xml_preprocess_enabled', 10, 1 );

    Once you’ve done that, you’ll be able to use XPath queries to grab the specific “param” elements you need. For example:

    {param[@name="Размер"]}
    {param[@name="Рулевая колонка"]}
    {param[@name="Педали"]}

    For attributes with multiple values that you want imported as attributes, be sure to convert the commas to pipes with a PHP function in the import:

    [str_replace(", ","|",{param[@name="Размер"]})]

    Thread Starter ilyapokrov

    (@ilyapokrov)

    @wpallimport,
    Thank You for your help!

    I have more questions that I will ask in another topic. But I have dealt with this issue.

    Thank you again!

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

The topic ‘Selecting an attribute by name’ is closed to new replies.