Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaevas committed Jan 3, 2016
1 parent 188eac1 commit 6ac21aa
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 128 deletions.
6 changes: 3 additions & 3 deletions Model/Source/Config/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function __construct(
$this->_fileName = $fileName;
$this->_idAttributes = array_replace($this->_idAttributes, $idAttributes);
$this->_schemaFile = $schemaLocator->getSchema();
$this->_isValidated = $validationState->isValidated();
$this->_perFileSchema = $schemaLocator->getPerFileSchema() &&
$this->_isValidated ? $schemaLocator->getPerFileSchema() : null;
$this->validationState = $validationState;
$this->_perFileSchema = $schemaLocator->getPerFileSchema() && $validationState->isValidationRequired()
? $schemaLocator->getPerFileSchema() : null;
$this->_domDocumentClass = $domDocumentClass;
$this->_defaultScope = $defaultScope;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/Source/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Magento\Framework\App\Filesystem\DirectoryList;

abstract class AbstractType extends \Magento\Framework\Object {
abstract class AbstractType extends \Magento\Framework\DataObject {

const IMPORT_DIR = 'var/import';

Expand Down
5 changes: 5 additions & 0 deletions Model/Source/Type/Ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public function uploadSource()
$sourceFilePath = $this->getData($this->_code . '_file_path');
$fileName = basename($sourceFilePath);
$filePath = $this->_directory->getAbsolutePath($this->getImportPath() . '/' . $fileName);

$filesystem = new \Magento\Framework\Filesystem\Io\File();
$filesystem->setAllowCreateFolders(true);
$filesystem->checkAndCreateFolder($this->_directory->getAbsolutePath($this->getImportPath()));

$result = $client->read($sourceFilePath, $filePath);

if($result) {
Expand Down
5 changes: 4 additions & 1 deletion Plugin/Block/Import/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function beforeSetForm(\Magento\ImportExport\Block\Adminhtml\Import\Edit\
$fileFieldset->setClass('source-fieldset ' . $oldClass);

$types = $this->_config->get();
$sources = [['label' => __('-- Please Select --'), 'value' => '']];
$sources = [
['label' => __('-- Please Select --'), 'value' => ''],
['label' => __('File'), 'value' => 'file']
];
foreach ($types as $typeName => $type) {
$sources[] = ['label' => $type['label'], 'value' => $typeName];
}
Expand Down
8 changes: 4 additions & 4 deletions Plugin/Model/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Import extends \Magento\ImportExport\Model\Import {
* @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig
* @param \Magento\ImportExport\Model\Import\ConfigInterface $importConfig
* @param \Magento\ImportExport\Model\Import\Entity\Factory $entityFactory
* @param \Magento\ImportExport\Model\Resource\Import\Data $importData
* @param \Magento\ImportExport\Model\Export\Adapter\CsvFactory $csvFactory
* @param \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory
* @param \Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory
Expand All @@ -47,12 +46,12 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $coreConfig,
\Magento\ImportExport\Model\Import\ConfigInterface $importConfig,
\Magento\ImportExport\Model\Import\Entity\Factory $entityFactory,
\Magento\ImportExport\Model\Resource\Import\Data $importData,
\Magento\ImportExport\Model\ResourceModel\Import\Data $importData,
\Magento\ImportExport\Model\Export\Adapter\CsvFactory $csvFactory,
\Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory,
\Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory,
\Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory,
\Magento\Indexer\Model\IndexerRegistry $indexerRegistry,
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
\Magento\ImportExport\Model\History $importHistoryModel,
\Magento\Framework\Stdlib\DateTime\DateTime $localeDate,
array $data = []
Expand Down Expand Up @@ -88,7 +87,8 @@ public function uploadSource()
{
$result = null;

if($sourceType = $this->getImportSource()) {
if($this->getImportSource() && $this->getImportSource() != 'file') {
$sourceType = $this->getImportSource();
$source = $this->_helper->getSourceModelByType($sourceType);
$source->setData($this->getData());

Expand Down
207 changes: 90 additions & 117 deletions Plugin/Model/Import/Product.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion etc/import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/ImportExport/etc/import.xsd">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
<entity name="catalog_product" label="Products" model="Firebear\ImportExport\Model\Import\Product" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
</config>
2 changes: 1 addition & 1 deletion view/adminhtml/templates/import/form/before.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/** @var $block \Magento\ImportExport\Block\Adminhtml\Import\Edit\Before */
?>
<script>
require(['jquery', 'prototype'], function(jQuery){
require(['jquery', 'Magento_Ui/js/modal/alert', 'prototype'], function(jQuery){

//<![CDATA[
// Temporary Class will be replaced after refactoring of import/export functionality
Expand Down

0 comments on commit 6ac21aa

Please sign in to comment.