WC_Product_CSV_Importer::__construct()publicWC 1.0

Initialize importer.

Метод класса: WC_Product_CSV_Importer{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->__construct( $file, $params );
$file(строка) (обязательный)
File to read.
$params(массив)
Arguments for the parser.
По умолчанию: array()

Код WC_Product_CSV_Importer::__construct() WC 8.7.0

public function __construct( $file, $params = array() ) {
	$default_args = array(
		'start_pos'        => 0, // File pointer start.
		'end_pos'          => -1, // File pointer end.
		'lines'            => -1, // Max lines to read.
		'mapping'          => array(), // Column mapping. csv_heading => schema_heading.
		'parse'            => false, // Whether to sanitize and format data.
		'update_existing'  => false, // Whether to update existing items.
		'delimiter'        => ',', // CSV delimiter.
		'prevent_timeouts' => true, // Check memory and time usage and abort if reaching limit.
		'enclosure'        => '"', // The character used to wrap text in the CSV.
		'escape'           => "\0", // PHP uses '\' as the default escape character. This is not RFC-4180 compliant. This disables the escape character.
	);

	$this->params = wp_parse_args( $params, $default_args );
	$this->file   = $file;

	if ( isset( $this->params['mapping']['from'], $this->params['mapping']['to'] ) ) {
		$this->params['mapping'] = array_combine( $this->params['mapping']['from'], $this->params['mapping']['to'] );
	}

	// Import mappings for CSV data.
	include_once dirname( dirname( __FILE__ ) ) . '/admin/importers/mappings/mappings.php';

	$this->read_file();
}