Reputation: 446
I have export my variations product from woocomerce using standart WP export stuff, how to import them back? When I use import WP write to me all done, but in products variations did not appear
Upvotes: 0
Views: 202
Reputation: 76
It took me hours to figure out why the post_parent field (for WooCommerce product Variations, in my case) wouldn't import using the integrated WordPress Export/Import. I ended up looking in the import plugin files and that's where I found the answer. It turns out it only applies the post_parent field, if the parent ID being referenced is contained in the same import. Which is silly since Products and Variations have to be exported as separate XML files.
Anyway, I temporarily added one line of code to the wordpress-importer.php file to get my import to work. Obviously, you shouldn't go around hacking plugins, but this is what worked for me:
$post_parent = (int) $post['post_parent'];
if ( $post_parent ) {
// if we already know the parent, map it to the new local ID
if ( isset( $this->processed_posts[$post_parent] ) ) {
$post_parent = $this->processed_posts[$post_parent];
// otherwise record the parent for later
} else {
$this->post_orphans[intval($post['post_id'])] = $post_parent;
$post_parent = 0;
}
$post_parent = (int) $post['post_parent']; // ADDED THIS LINE
}
Upvotes: 1
Reputation: 446
Problem was in field post_parent. I don't know why, but in database this field set 0 and not from .xml file. My resolve of problem: Set manually in db parent post id
Upvotes: 0