/**
  * @param $filePath Absolute file path to CSV file
  */
 public function setFile($filePath)
 {
     if (!file_exists($filePath)) {
         throw new FileNotFoundException();
     }
     // Hacky but quick fix for https://github.com/cedricblondeau/magento2-module-catalog-import-command/issues/1
     $pathInfo = pathinfo($filePath);
     $validate = $this->importModel->validateSource($this->csvSourceFactory->create(['file' => $pathInfo['basename'], 'directory' => $this->readFactory->create($pathInfo['dirname'])]));
     if (!$validate) {
         throw new \InvalidArgumentException();
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource $source)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'validateSource');
     if (!$pluginInfo) {
         return parent::validateSource($source);
     } else {
         return $this->___callPlugins('validateSource', func_get_args(), $pluginInfo);
     }
 }
예제 #3
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Entity is unknown
  */
 public function testValidateSourceException()
 {
     $source = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Import\\AbstractSource', [], '', false);
     $this->_model->validateSource($source);
 }
 protected function _validateData($dataArray)
 {
     $source = $this->arrayAdapterFactory->create(array('data' => $dataArray));
     $this->validationResult = $this->importModel->validateSource($source);
     return $this->validationResult;
 }