◆ __construct()
__construct |
( |
File |
$file | ) |
|
Constructor
- Parameters
-
File | $file | File Driver used for writing CSV |
Definition at line 43 of file Csv.php.
◆ appendData()
appendData |
( |
|
$file, |
|
|
|
$data, |
|
|
|
$mode = 'w' |
|
) |
| |
Replace the saveData method by allowing to select the input mode
- Parameters
-
string | $file | |
array | $data | |
string | $mode | |
- Returns
- $this
- Exceptions
-
Definition at line 152 of file Csv.php.
155 foreach (
$data as $dataRow) {
156 $this->file->filePutCsv($fileHandler, $dataRow, $this->_delimiter, $this->_enclosure);
158 fclose($fileHandler);
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
◆ getData()
Retrieve CSV file data as array
- Parameters
-
- Returns
- array
- Exceptions
-
Definition at line 91 of file Csv.php.
94 if (!file_exists(
$file)) {
95 throw new \Exception(
'File "' .
$file .
'" does not exist');
99 while ($rowData = fgetcsv($fh, $this->_lineLength, $this->_delimiter, $this->_enclosure)) {
◆ getDataPairs()
getDataPairs |
( |
|
$file, |
|
|
|
$keyIndex = 0 , |
|
|
|
$valueIndex = 1 |
|
) |
| |
Retrieve CSV file data as pairs
- Parameters
-
string | $file | |
int | $keyIndex | |
int | $valueIndex | |
- Returns
- array
Definition at line 114 of file Csv.php.
118 foreach ($csvData as $rowData) {
119 if (isset($rowData[$keyIndex])) {
120 $data[$rowData[$keyIndex]] = isset($rowData[$valueIndex]) ? $rowData[$valueIndex] :
null;
◆ saveData()
saveData |
( |
|
$file, |
|
|
|
$data |
|
) |
| |
Saving data row array into file
- Parameters
-
- Returns
- $this
- Exceptions
-
Definition at line 136 of file Csv.php.
appendData($file, $data, $mode='w')
◆ setDelimiter()
setDelimiter |
( |
|
$delimiter | ) |
|
Set CSV column delimiter
- Parameters
-
- Returns
- \Magento\Framework\File\Csv
Definition at line 66 of file Csv.php.
68 $this->_delimiter = $delimiter;
◆ setEnclosure()
setEnclosure |
( |
|
$enclosure | ) |
|
Set CSV column value enclosure
- Parameters
-
- Returns
- \Magento\Framework\File\Csv
Definition at line 78 of file Csv.php.
80 $this->_enclosure = $enclosure;
◆ setLineLength()
Set max file line length
- Parameters
-
- Returns
- \Magento\Framework\File\Csv
Definition at line 54 of file Csv.php.
56 $this->_lineLength = $length;
◆ $_delimiter
◆ $_enclosure
◆ $_lineLength
◆ $file
The documentation for this class was generated from the following file:
- vendor/magento/framework/File/Csv.php