Answer the question
In order to leave comments, you need to log in
How to quickly create 99999 simple products?
You need to upload 99999 simple downloadable products to woocommerce, which differ from each other only in the name, article number, and number in the URL. This is what the piece of .csv file looks like that I'm trying to upload to the site.
"Артикул";"Имя";"В наличии?";"Запасы";"Базовая цена";"URL загрузки";"Лимит загрузок";"Тип"
"00001";"00001";1;1;99;"/ticket.png?number=00001";1;"simple, downloadable"
"00002";"00002";1;1;99;"/ticket.php?number=00002";1;"simple, downloadable"
"00003";"00003";1;1;99;"/ticket.php?number=00003";1;"simple, downloadable"
"00004";"00004";1;1;99;"/ticket.php?number=00004";1;"simple, downloadable"
"00005";"00005";1;1;99;"/ticket.php?number=00005";1;"simple, downloadable"
"00006";"00006";1;1;99;"/ticket.php?number=00006";1;"simple, downloadable"
"00007";"00007";1;1;99;"/ticket.php?number=00007";1;"simple, downloadable"
"00008";"00008";1;1;99;"/ticket.php?number=00008";1;"simple, downloadable"
"00009";"00009";1;1;99;"/ticket.php?number=00009";1;"simple, downloadable"
Answer the question
In order to leave comments, you need to log in
Adding products or SQL records with a query is not a good idea, because in this case you are bypassing the VI.
It is better to use Woocommerce REST API capabilities. Or as an option plugin WP All Import + Woocommerce Addon and import from CSV file.
You can’t throw it directly, of course, but anything unpleasant is possible, because when you add a record, a lot of things happen.
So, test how many as much as possible and you can throw records in one pass using standard means. everything is there except to pull up the thumbnail.
<?php
/**
* @package TAXO CRM
* @author WP_Panda
* @version 0.2.1
*/
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
$metas = [
'key_1' => 1,
'key_2' => 1,
'key_3' => 1,
'key_3' => 1
];
$post_data = [
'post_content' => 'Контент контент контент',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => [ 8, 39 ]
];
$start = microtime(true);
$i = 1;
while ( $i <= 1000 ) {
$post_data[ 'post_title' ] = 'Запись ' . $i;
$post_id = wp_insert_post( $post_data );
foreach ( $metas as $meta_key => $meta_val ) {
update_post_meta( $post_id, $meta_key, $meta_val );
}
$i ++;
}
$time = microtime(true) - $start;
printf( 'Время выполнения: %s мс', $time );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question