• Resolved notelseit

    (@notelseit)


    I have to map over 3000 categories, I have created this function but the categories are not mapped are imported with the IDs where is the error?

    <?php // Funzione per la mappatura delle categorie
    function map_categories($category_id) {
        $category_mapping = array(
            '14497' => 'Uomo',
            '14498' => 'Profumi',
            '14499' => 'Corpo & Bagno',
            '14500' => 'Trattamenti Viso',
            '14501' => 'Make-Up',
            '14502' => 'Capelli',
            '14503' => 'Protezione Solare',
            '14504' => 'Regali',
            '14507' => 'Parafarmacia',
            '14508' => 'Profumi',
            '14509' => 'Corpo & Bagno',
            '14510' => 'Trattamenti Viso',
            '14511' => 'Regali',
            '14512' => 'Capelli',
            '14513' => 'ADOLFO DOMINGUEZ',
            '14514' => 'ALVAREZ G?“MEZ',
            '15008' => 'Uomo',
            '18027' => 'Drogheria',
            // Aggiungi altri ID e categorie secondo necessità
        );
    
        // Verifica se l'ID della categoria esiste nella mappatura
        if (array_key_exists($category_id, $category_mapping)) {
            return $category_mapping[$categories];
        } else {
            // Restituisci una categoria di default se l'ID non è mappato
            return 'Categoria non mappata';
        }
    }
    
    ?>

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

    (@wpallimport)

    Hi @notelseit,

    Inside the array_key_exists IF conditional, you should return this instead of what you’re currently returning:

    return $category_mapping[ $category_id ];

    With that said, our free plugin doesn’t support custom PHP functions in the template, so you’ll need to contact us at https://www.wpallimport.com/support/ if you have more questions about this.

    Thread Starter notelseit

    (@notelseit)

    Sorry, I will proceed to the site you indicated for support , thank you

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