WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Product_CSV_Exporter::prepare_data_to_export() WC 3.1.0

Prepare data for export.

Это метод класса: WC_Product_CSV_Exporter

Возвращает

Null. Ничего.

Использование

$WC_Product_CSV_Exporter = new WC_Product_CSV_Exporter();
$var = $WC_Product_CSV_Exporter->prepare_data_to_export();

Список изменений

С версии 3.1.0 Введена.

Код WC Product CSV Exporter::prepare data to export: woocommerce/includes/export/class-wc-product-csv-exporter.php WC 3.6.5

<?php
public function prepare_data_to_export() {
	$args = array(
		'status'   => array( 'private', 'publish', 'draft', 'future', 'pending' ),
		'type'     => $this->product_types_to_export,
		'limit'    => $this->get_limit(),
		'page'     => $this->get_page(),
		'orderby'  => array(
			'ID' => 'ASC',
		),
		'return'   => 'objects',
		'paginate' => true,
	);

	if ( ! empty( $this->product_category_to_export ) ) {
		$args['category'] = $this->product_category_to_export;
	}
	$products = wc_get_products( apply_filters( "woocommerce_product_export_{$this->export_type}_query_args", $args ) );

	$this->total_rows  = $products->total;
	$this->row_data    = array();
	$variable_products = array();

	foreach ( $products->products as $product ) {
		// Check if the category is set, this means we need to fetch variations seperately as they are not tied to a category.
		if ( ! empty( $args['category'] ) && $product->is_type( 'variable' ) ) {
			$variable_products[] = $product->get_id();
		}

		$this->row_data[] = $this->generate_row_data( $product );
	}

	// If a category was selected we loop through the variations as they are not tied to a category so will be excluded by default.
	if ( ! empty( $variable_products ) ) {
		foreach ( $variable_products as $parent_id ) {
			$products = wc_get_products(
				array(
					'parent' => $parent_id,
					'type'   => array( 'variation' ),
					'return' => 'objects',
					'limit'  => -1,
				)
			);

			if ( ! $products ) {
				continue;
			}

			foreach ( $products as $product ) {
				$this->row_data[] = $this->generate_row_data( $product );
			}
		}
	}
}