diff --git a/Console/Command/Category/ImportCategoryCsv.php b/Console/Command/Category/ImportCategoryCsv.php new file mode 100644 index 0000000..5e3d3ed --- /dev/null +++ b/Console/Command/Category/ImportCategoryCsv.php @@ -0,0 +1,101 @@ +readFactory = $readFactory; + + $this->directory_list = $directory_list; + } + + protected function configure() + { + + $this->setName('fastsimpleimportdemo:category:importcsv') + ->setDescription('Import Category from CSV'); + $this->setBehavior(Import::BEHAVIOR_ADD_UPDATE); + $this->setEntityCode('catalog_category'); + + parent::configure(); + } + + /** + * @return array + */ + protected function getEntities() + { + /* + $data[] = array( + '_root' => 'Default Category', + '_category' => 'FireGento TestCategory', + 'description' => 'Test2', + 'is_active' => '1', + 'include_in_menu' => '1', + 'meta_description' => 'Meta Test', + 'available_sort_by' => 'position', + 'default_sort_by' => 'position', + 'is_anchor' => '1' + ); + */ + + $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); + } +} \ No newline at end of file diff --git a/Console/Command/Product/DeleteAll.php b/Console/Command/Product/DeleteAll.php index 527ae7d..93e0e7a 100644 --- a/Console/Command/Product/DeleteAll.php +++ b/Console/Command/Product/DeleteAll.php @@ -14,9 +14,6 @@ class DeleteAll extends AbstractImportCommand { - - - protected function configure() { $this->setName('fastsimpleimportdemo:products:deleteall') diff --git a/README.md b/README.md index 20fba28..ed9ae64 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Installation Instructions with Composer(Master Branch) ### Import customers `bin/magento fastsimpleimportdemo:customers:import` + + ### Delete all customers: `bin/magento fastsimpleimportdemo:customers:deleteall` @@ -57,3 +59,5 @@ Installation Instructions with Composer(Master Branch) ### Import Categories: `bin/magento fastsimpleimportdemo:category:import` +### Import products from CSV File:(currently building) +`bin/magento fastsimpleimportdemo:category:importcsv` diff --git a/composer.json b/composer.json index 96b4be4..5e06e3a 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,10 @@ { "name": "Team FireGento", "email": "team@firegento.com" + }, + { + "name": "Team AI Art", + "email": "hamilton@aiart.io" } ], "autoload": { @@ -20,7 +24,7 @@ "registration.php" ], "psr-4": { - "FireGento\\FastSimpleImportDemo\\": "" + "Firegento\\FastSimpleImportDemo\\": "" } } } diff --git a/etc/di.xml b/etc/di.xml index e13029a..77cbdeb 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -21,7 +21,7 @@ FireGento\FastSimpleImportDemo\Console\Command\Customer\ImportCustomer FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategory - + FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategoryCsv FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategoryMultiStoreView