Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in import category using css #8

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Console/Command/Category/ImportCategoryCsv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
namespace FireGento\FastSimpleImportDemo\Console\Command\Category;

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 ImportCategoryCsv extends AbstractImportCommand
{
const IMPORT_FILE = "importCategoryFile.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: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);
}
}
3 changes: 0 additions & 3 deletions Console/Command/Product/DeleteAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
class DeleteAll extends AbstractImportCommand
{




protected function configure()
{
$this->setName('fastsimpleimportdemo:products:deleteall')
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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`
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
{
"name": "Team FireGento",
"email": "[email protected]"
},
{
"name": "Team AI Art",
"email": "[email protected]"
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"FireGento\\FastSimpleImportDemo\\": ""
"Firegento\\FastSimpleImportDemo\\": ""
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<item name="import_customer" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Customer\ImportCustomer</item>
<item name="import_category" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategory</item>

<item name="import_category_csv" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategoryCsv</item>

<item name="import_category_multi" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategoryMultiStoreView</item>

Expand Down