Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajason committed Jan 19, 2017
1 parent affdf93 commit 8f0e7f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [1.3.0](https://github.com/webshopapps/m2Matrixrate/tree/1.3.0) (2017-01-19)
[Full Changelog](https://github.com/webshopapps/m2Matrixrate/compare/1.2.9...1.3.0)

## [1.2.9](https://github.com/webshopapps/m2Matrixrate/tree/1.2.9) (2016-12-22)
[Full Changelog](https://github.com/webshopapps/m2Matrixrate/compare/1.2.8...1.2.9)

Expand Down
15 changes: 12 additions & 3 deletions src/Model/ResourceModel/Carrier/Matrixrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class Matrixrate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* * @var \Magento\Framework\Filesystem\Directory\ReadFactory
*/
private $_readFactory;
/**
* * @var \Magento\Framework\Filesystem
*/
protected $_filesystem;

/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
Expand All @@ -151,6 +155,7 @@ class Matrixrate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
* @param \Magento\Framework\Filesystem $filesystem
* @param string|null $resourcePrefix
*/
public function __construct(
Expand All @@ -162,6 +167,7 @@ public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory,
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory,
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
\Magento\Framework\Filesystem $filesystem,
$resourcePrefix = null
) {
parent::__construct($context, $resourcePrefix);
Expand All @@ -172,6 +178,7 @@ public function __construct(
$this->_countryCollectionFactory = $countryCollectionFactory;
$this->_regionCollectionFactory = $regionCollectionFactory;
$this->_readFactory = $readFactory;
$this->_filesystem = $filesystem;
}

/**
Expand Down Expand Up @@ -327,9 +334,11 @@ public function uploadAndImport(\Magento\Framework\DataObject $object)
$this->_importErrors = [];
$this->_importedRows = 0;

$uploadDirectory = $this->_readFactory->create(ini_get('upload_tmp_dir') ?: sys_get_temp_dir());
$path = $uploadDirectory->getRelativePath($csvFile);
$stream = $uploadDirectory->openFile($path);
//M2-20
$tmpDirectory = ini_get('upload_tmp_dir')? $this->_readFactory->create(ini_get('upload_tmp_dir'))
: $this->_filesystem->getDirectoryRead(DirectoryList::SYS_TMP);
$path = $tmpDirectory->getRelativePath($csvFile);
$stream = $tmpDirectory->openFile($path);

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

0 comments on commit 8f0e7f6

Please sign in to comment.