-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
228 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* * | ||
* * Copyright © Elias Kotlyar - All rights reserved. | ||
* * See LICENSE.md bundled with this module for license details. | ||
* | ||
*/ | ||
namespace FireGento\FastSimpleImportDemo\Console\Command\Category; | ||
|
||
use FireGento\FastSimpleImportDemo\Console\Command\AbstractImportCommand; | ||
use Magento\ImportExport\Model\Import; | ||
|
||
/** | ||
* Class TestCommand | ||
* @package FireGento\FastSimpleImport2\Console\Command | ||
* | ||
*/ | ||
class ImportCategoryMultiStoreView extends AbstractImportCommand | ||
{ | ||
|
||
|
||
protected function configure() | ||
{ | ||
$this->setName('fastsimpleimportdemo:category:import') | ||
->setDescription('Import Category'); | ||
|
||
$this->setBehavior(Import::BEHAVIOR_APPEND); | ||
$this->setEntityCode('catalog_category'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getEntities() | ||
{ | ||
$data[] = array( | ||
'_root' => 'Default Category', | ||
'_category' => 'FireGento TestCategory DE', | ||
'description' => 'Test2', | ||
'is_active' => '1', | ||
'include_in_menu' => '1', | ||
'meta_description' => 'Meta Test', | ||
'available_sort_by' => 'position', | ||
'default_sort_by' => 'position', | ||
'is_anchor' => '1' | ||
); | ||
$data[] = array( | ||
'_store' => 'en', | ||
'name' => 'FireGento TestCategory EN', | ||
'description' => 'StoreViewLevel' | ||
); | ||
return $data; | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* * | ||
* * Copyright © Elias Kotlyar - All rights reserved. | ||
* * See LICENSE.md bundled with this module for license details. | ||
* | ||
*/ | ||
namespace FireGento\FastSimpleImportDemo\Console\Command\Customer; | ||
use Magento\ImportExport\Model\Import; | ||
use FireGento\FastSimpleImportDemo\Console\Command\AbstractExportCommand; | ||
/** | ||
* Class TestCommand | ||
* @package FireGento\FastSimpleImport2\Console\Command | ||
* | ||
*/ | ||
class ExportCustomer extends AbstractExportCommand | ||
{ | ||
|
||
|
||
protected function configure() | ||
{ | ||
$this->setName('fastsimpleimportdemo:customers:export') | ||
->setDescription('Export Customers'); | ||
$this->setEntityCode('customer'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
namespace FireGento\FastSimpleImportDemo\Console\Command\Product; | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
use FireGento\FastSimpleImportDemo\Console\Command\AbstractImportCommand; | ||
use Magento\Framework\App\ObjectManagerFactory; | ||
use Magento\ImportExport\Model\Import; | ||
use League\Csv\Reader; | ||
|
||
class ImportCsv extends AbstractImportCommand | ||
{ | ||
const IMPORT_FILE = "importfile.csv"; | ||
|
||
/** | ||
* @var \Magento\Framework\Filesystem\Directory\ReadFactory | ||
*/ | ||
private $readFactory; | ||
/** | ||
* @var DirectoryList | ||
*/ | ||
private $directory_list; | ||
|
||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ObjectManagerFactory $objectManagerFactory | ||
*/ | ||
public function __construct( | ||
ObjectManagerFactory $objectManagerFactory, | ||
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, | ||
\Magento\Framework\App\Filesystem\DirectoryList $directory_list | ||
) | ||
{ | ||
|
||
parent::__construct($objectManagerFactory); | ||
|
||
|
||
$this->readFactory = $readFactory; | ||
|
||
$this->directory_list = $directory_list; | ||
} | ||
|
||
protected function configure() | ||
{ | ||
|
||
$this->setName('fastsimpleimportdemo:products:importcsv') | ||
->setDescription('Import Products from CSV'); | ||
$this->setBehavior(Import::BEHAVIOR_ADD_UPDATE); | ||
$this->setEntityCode('catalog_product'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getEntities() | ||
{ | ||
$csvIterationObject = $this->readCSV(); | ||
$data = array(); | ||
// Do mapping here: | ||
foreach($csvIterationObject as $row){ | ||
$data[] = $row; | ||
} | ||
// Mapping end | ||
//var_dump($data); | ||
//die(); | ||
return $data; | ||
} | ||
|
||
protected function readCSV() | ||
{ | ||
$csvObj = Reader::createFromString($this->readFile(static::IMPORT_FILE)); | ||
$csvObj->setDelimiter(','); | ||
$results = $csvObj->fetchAssoc(); | ||
return $results; | ||
|
||
} | ||
|
||
protected function readFile($fileName) | ||
{ | ||
$path = $this->directory_list->getRoot(); | ||
$directoryRead = $this->readFactory->create($path); | ||
return $directoryRead->readFile($fileName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters