Magento 2で作業していますが、ftp接続でファイルを読み込む必要があります。私はftpにログインすることができますが、私はcsvファイルを読むことができません。magento 2 read csv from ftpは文字列ではなく配列を返します
use Magento\Framework\File\Csv;
use Magento\Framework\Filesystem\Io\Ftp;
class MyClass {
protected $_csvprocessor;
protected $_ftp;
public function __construct(Csv $csvprocessor, Ftp $ftp) {
$this->_csvprocessor = $csvprocessor;
$this->_ftp = $ftp;
}
public function getCsv() {
$conn = $this->_ftp->open($params); // this works, I can successfully login to ftp
$filecsv = $this->_ftp->read($remotepathtofile); // this gets me the file but it is a string, not an array with the csv data
$this->_csvprocessor->getData($remotepathtofile); // this doesn't work with remote file, only with local path (eg: magentoroot/var/import/file.csv)
}
}
$this->_csvprocessor->getData()
を返しますが、リモートファイルの代わりに、ローカルからと同じように、私は、配列としてCSVを読むことができますどのように私はこれまでのところ(私はすべての不要な部分をカット)何をしましたか?