Support » Plugin: WooCommerce Product Generator » An easy way to speed up your plugin

  • Hello.

    Your plugin has one problem. When there are more than 1000 products – generation slows down – because WordPress generates slugs for products itself – this process is very resourceful.

    I sped up the generation in your plugin like this:

    public static function create_product() {

    static $i = 0;

    $post_id = wp_insert_post( array(
    ‘post_type’ => ‘product’,
    ‘post_title’ => $title,
    ‘post_name’ => ‘product_’ . microtime() . $i,
    ‘post_excerpt’ => $excerpt,
    ‘post_content’ => $content,
    ‘post_status’ => ‘publish’,
    ‘post_author’ => $user_id
    ) );

    as you can see, I force the post_name for the product:
    ‘post_name’ => ‘product_’ . microtime() . $i,

    you can do it differently, it is important that WordPress does not do this – it uses heavy SQL-queries

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘An easy way to speed up your plugin’ is closed to new replies.