2016-07-17 2 views
-1

erhält Ich möchte Produkte in Wortpresse von der URL importieren.Wie man Produkt in wordpress woocommerce von der URL importiert und Befehl

Ich möchte die Produkttabelle vollständig kennen, ich meine, dass ich meine URL-Tabellen mit woo Commerce-Tabelle zuordnen möchte. Was sind die Produkte und Attribute und Preise und Variablen Tabelle in Woo Commerce?

Zum Beispiel

INSERT INTO `catalog_product_website` (`product_id`, `website_id`) VALUES 
+1

Sie können meine Antwort akzeptieren, wenn es Ihr Problem gelöst, indem das graue Häkchen unterhalb der Stimmen Zähler klicken. Danke =) – JazZ

Antwort

1

Die Wordpress WooCommerce speichert Produkte Informationen in wp_post (post_type = Produkt) und in wp_postmeta (meta_key und meta_value für eine post_id).

So zu speichern neue Produkte, die Art und Weise, werden Sie, so etwas zu tun haben:

Um neues Produkt in derwp_post Tabelle hinzufügen:

$post = array(
    'post_author' => $user_id, 
    'post_content' => '', 
    'post_status' => "publish", 
    'post_title' => $product->part_num, 
    'post_parent' => '', 
    'post_type' => "product", 
); 

//Create post 
$post_id = wp_insert_post($post, $wp_error); 
if($post_id){ 
    $attach_id = get_post_meta($product->parent_id, "_thumbnail_id", true); 
    add_post_meta($post_id, '_thumbnail_id', $attach_id); 
} 

die Kategorie festzulegen und die Art des neuen Produktes:

wp_set_object_terms($post_id, 'Races', 'product_cat'); 
wp_set_object_terms($post_id, 'simple', 'product_type'); 

Und dann legen Sie die Werte in wp_postmeta Tabelle:

update_post_meta($post_id, '_visibility', 'visible'); 
update_post_meta($post_id, '_stock_status', 'instock'); 
update_post_meta($post_id, 'total_sales', '0'); 
update_post_meta($post_id, '_downloadable', 'yes'); 
update_post_meta($post_id, '_virtual', 'yes'); 
update_post_meta($post_id, '_regular_price', "1"); 
update_post_meta($post_id, '_sale_price', "1"); 
update_post_meta($post_id, '_purchase_note', ""); 
update_post_meta($post_id, '_featured', "no"); 
update_post_meta($post_id, '_weight', ""); 
update_post_meta($post_id, '_length', ""); 
update_post_meta($post_id, '_width', ""); 
update_post_meta($post_id, '_height', ""); 
update_post_meta($post_id, '_sku', ""); 
update_post_meta($post_id, '_product_attributes', array()); 
update_post_meta($post_id, '_sale_price_dates_from', ""); 
update_post_meta($post_id, '_sale_price_dates_to', ""); 
update_post_meta($post_id, '_price', "1"); 
update_post_meta($post_id, '_sold_individually', ""); 
update_post_meta($post_id, '_manage_stock', "no"); 
update_post_meta($post_id, '_backorders', "no"); 
update_post_meta($post_id, '_stock', ""); 

Hoffe, es hilft.

Quelle: How to add product in woocommerce with php code

+0

@LoicTheAztec Danke. – JazZ

Verwandte Themen