WordPress at Your Fingertips
function is not described

WC_Product_CSV_Importer::__construct() public WC 1.0

Initialize importer.

{} It's a method of the class: WC_Product_CSV_Importer{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->__construct( $file, $params );
$file(string) (required)
File to read.
$params(array)
Arguments for the parser.
Default: array()

Code of WC_Product_CSV_Importer::__construct() WC 5.8.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();
}