WC_Product_CSV_Importer::__construct()
Initialize importer.
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()
WC_Product_CSV_Importer::__construct() WC Product CSV Importer:: construct code WC 7.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(); }