Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Io;

class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb
{
Expand Down Expand Up @@ -255,12 +256,14 @@ public function uploadAndImport(\Magento\Framework\Object $object)
$this->_importErrors = [];
$this->_importedRows = 0;

$tmpDirectory = $this->_filesystem->getDirectoryRead(DirectoryList::SYS_TMP);
$path = $tmpDirectory->getRelativePath($csvFile);
$stream = $tmpDirectory->openFile($path);
$stream = new \Magento\Framework\Io\File();
$info = pathinfo($csvFile);
$stream->open(array('path' => $info['dirname']));
$stream->streamOpen($info['basename'], 'r');

// check and skip headers
$headers = $stream->readCsv();
$headers = $stream->streamReadCsv();

if ($headers === false || count($headers) < 5) {
$stream->close();
throw new \Magento\Framework\Model\Exception(__('Please correct Table Rates File Format.'));
Expand Down Expand Up @@ -290,7 +293,7 @@ public function uploadAndImport(\Magento\Framework\Object $object)
];
$adapter->delete($this->getMainTable(), $condition);

while (false !== ($csvLine = $stream->readCsv())) {
while (false !== ($csvLine = $stream->streamReadCsv())) {
$rowNumber++;

if (empty($csvLine)) {
Expand Down