Merge pull request #22736 from woocommerce/fix/22703

Importer -  Variations cannot be drafts - set to private.
This commit is contained in:
Mike Jolley 2019-02-19 09:45:17 +00:00 committed by GitHub
commit 55bd0e7937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 16 deletions

View File

@ -236,6 +236,12 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
unset( $data['manage_stock'], $data['stock_status'], $data['backorders'], $data['low_stock_amount'] );
}
if ( 'variation' === $object->get_type() ) {
if ( isset( $data['status'] ) && -1 === $data['status'] ) {
$data['status'] = 0; // Variations cannot be drafts - set to private.
}
}
if ( 'importing' === $object->get_status() ) {
$object->set_status( 'publish' );
$object->set_slug( '' );
@ -644,13 +650,15 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
}
// If the attribute does not exist, create it.
$attribute_id = wc_create_attribute( array(
'name' => $raw_name,
'slug' => $attribute_name,
'type' => 'select',
'order_by' => 'menu_order',
'has_archives' => false,
) );
$attribute_id = wc_create_attribute(
array(
'name' => $raw_name,
'slug' => $attribute_name,
'type' => 'select',
'order_by' => 'menu_order',
'has_archives' => false,
)
);
if ( is_wp_error( $attribute_id ) ) {
throw new Exception( $attribute_id->get_error_message(), 400 );
@ -661,15 +669,18 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
register_taxonomy(
$taxonomy_name,
apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ),
apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array(
'labels' => array(
'name' => $raw_name,
),
'hierarchical' => true,
'show_ui' => false,
'query_var' => true,
'rewrite' => false,
) )
apply_filters(
'woocommerce_taxonomy_args_' . $taxonomy_name,
array(
'labels' => array(
'name' => $raw_name,
),
'hierarchical' => true,
'show_ui' => false,
'query_var' => true,
'rewrite' => false,
)
)
);
// Set product attributes global.