• Resolved ilyapokrov

    (@ilyapokrov)


    I upload affiliate products to the site.
    Tell me what to do with products that are not in the download file?
    I want to hide them from the catalog on the site, but keep product cards so that these products also participate in Google search and drive traffic to the site.

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

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

    (@wpallimport)

    Hi @ilyapokrov

    I want to hide them from the catalog on the site, but keep product cards so that these products also participate in Google search and drive traffic to the site.

    As long as you imported the products with a “New Items” import, you can leverage the “Delete posts that are no longer present in your file” option in the Import Settings: https://d.pr/i/bVlioA.

    Once that’s enabled, you’ll have to write some custom code that uses our wp_all_import_is_post_to_delete hook to change the product visibility to whatever you want and stop the deletion of the product: https://www.wpallimport.com/documentation/advanced/action-reference/#wp_all_import_is_post_to_delete.

    Here’s an example snippet that you can modify as needed:

    function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
        // Unless you want this code to execute for every import, check the import id    
        // if ( $import->id == 5 ) { ... }
        if ( $product = wc_get_product( $post_id ) ) {
            $product->set_catalog_visibility( 'hidden' );
            $product->save();
        }
        return false;
    }
    add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );
    Thread Starter ilyapokrov

    (@ilyapokrov)

    I did as you recommended to me.
    I used the snippet that you specified and added it in step 3 to the “Functions Editor” section.
    But the problem remained – WP all import did not delete the goods, but only made duplicates of all my goods. Products are still displayed in the catalog and on the site.

    Let me remind you of the problem. I add external/affiliate products. The partner’s file is changed daily – new products are added, old ones are deleted, the price changes. I need to make sure that products that are not in the new file are not deleted, but become hidden, do not appear in the catalog, but participate in a Google search and are accessible via a direct link. And those products that are in the file have been updated prices.

    I’m confused, please help me.

    Thank.

    Here is what I added in step 3 to the Functions Editor section:

    <?php
    function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
        // Unless you want this code to execute for every import, check the import id    
        // if ( $import->id == 5 ) { ... }
        if ( $product = wc_get_product( $post_id ) ) {
            $product->set_catalog_visibility( 'hidden' );
            $product->save();
        }
        return false;
    }
    add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );
    ?>
    • This reply was modified 4 years, 6 months ago by ilyapokrov.
    • This reply was modified 4 years, 6 months ago by ilyapokrov.
    Thread Starter ilyapokrov

    (@ilyapokrov)

    I figured it out. If I understand correctly, you cannot create new imports, the plugin cannot determine the goods. You must use a single import.
    Thanks for the help, the topic can be closed.
    One caveat – If I change the affiliate program with the same XML file, will I have to delete all the products and re-record them through a new import?
    Since in different affiliate offers – different affiliate URLs.

    Plugin Author WP All Import

    (@wpallimport)

    Hey @ilyapokrov

    If I understand correctly, you cannot create new imports, the plugin cannot determine the goods. You must use a single import.

    That’s correct, a “New Items” import can only update/delete posts that it previously created. It can’t recognize posts created manually or by other imports.

    One caveat – If I change the affiliate program with the same XML file, will I have to delete all the products and re-record them through a new import? Since in different affiliate offers – different affiliate URLs.

    I’m sorry, but I’m not sure if I understand the question.

    Can you elaborate on exactly how the data will be changing (e.g., different data with the same structure? completely different structure/file?) and what the desired results are after the update?

    Plugin Author WP All Import

    (@wpallimport)

    Hey @ilyapokrov

    It’s been a while since we’ve heard from you, so I’m going to mark this as resolved. You can follow up here if you still have questions. Anyone else reading this, please start a new topic.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Product Updates’ is closed to new replies.