• Resolved headplus

    (@headplus)


    Hi!

    I’m trying to make an xml file with some rules and i need your help!

    I have some products (woocommerce) and i want to export them but i want to change some data on XML…

    For example:
    2 products have in taxonomy the brand ”COLGATE”
    and
    3 products have in taxonomy the brand ”COLGATEFORKIDS”

    because the manufacturer is the ”PROCT&GRAMBLE” for both of them,

    how to indicate on XML for this 5 products as brand ”PROCT&GRAMBLE” ???

    Thank you in Advanced!

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

    (@wpallimport)

    Hi @headplus,

    Just to clarify, are you saying that you want to do something like this:

    IF brand is "COLGATE" 
    OR brand is "COLGATEFORKIDS" 
    AND manufacturer is "PROCT&GRAMBLE"
    Return "PROCT&GRAMBLE" as the brand
    
    ELSE
    Return whatever is in the brand taxonomy.

    Or, am I misunderstanding?

    Thread Starter headplus

    (@headplus)

    @wpallimport yes that’s it! You got it! :))
    What function I have to make? (Because I tryied something without results)

    Plugin Author WP All Import

    (@wpallimport)

    Hi @headplus,

    Okay, you’ll definitely need to write a function for that: https://www.wpallimport.com/documentation/export/pass-data-through-php-functions/. Here is an example that you can modify as needed:

    function my_get_brand( $brand, $manufacturer ) {
        if ( ( $brand == 'COLGATE' || $brand == 'COLGATEFORKIDS' ) && $manufacturer == 'PROCT&GRAMBLE' ) {
            return 'PROCT&GRAMBLE';
        } else {
            return $brand;
        }
    }

    This would be used in a Custom XML Feed like this:

    <brand>CDATABEGIN[my_get_brand({Brands},{Manufacturers})]CDATACLOSE</brand>

    This includes CDATA tags because of the ampersand, just be sure to replace {Brands} and {Manufacturers} with the correct export elements on your site.

    Thread Starter headplus

    (@headplus)

    I ‘ m really grateful for your reply!!!
    Thanks a lot!!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Making Rules for XML (HELP PLS!)’ is closed to new replies.