Skip to content

Commit

Permalink
Updated to PHP version 7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hafeez3000 committed Oct 19, 2017
2 parents 681fa74 + 370aae8 commit 3b127fd
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 30 deletions.
1 change: 1 addition & 0 deletions Console/Command/Category/ImportCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected function getEntities()
'meta_description' => 'Meta Test',
'available_sort_by' => 'position',
'default_sort_by' => 'position',
'is_anchor' => '1'
);
return $data;
}
Expand Down
59 changes: 59 additions & 0 deletions Console/Command/Category/ImportCategoryMultiStoreView.php
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;
}
}



30 changes: 30 additions & 0 deletions Console/Command/Customer/ExportCustomer.php
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();
}


}
2 changes: 1 addition & 1 deletion Console/Command/Orders/ExportOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function configure()
{
$this->setName('fastsimpleimportdemo:orders:export')
->setDescription('Export Orders ');
$this->setEntityCode('sales_order');
$this->setEntityCode('order');

parent::configure();
}
Expand Down
62 changes: 35 additions & 27 deletions Console/Command/Product/ImportConfigurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,50 @@ protected function configure()
*/
protected function getEntities()
{
$simpleProducts = [];
$configurableProduct = array(
$products = [];
$products [] = array(
'sku' => "SIMPLE-BLUE-SMALL",
'attribute_set_code' => 'Default',
'product_type' => 'simple',
'product_websites' => 'base',
'name' => 'FireGento Simple Product Blue,Size Small',
'price' => '1.0000',
'color' => 'blue',
'size' => 'S'
);
$products [] = array(
'sku' => "SIMPLE-RED-MIDDLE",
'attribute_set_code' => 'Default',
'product_type' => 'simple',
'product_websites' => 'base',
'name' => 'FireGento Simple Product Red,Size Middle',
'price' => '1.0000',
'color' => 'red',
'size' => 'M'
);

$products [] = array(
'sku' => 'CONFIG-Product',
'attribute_set_code' => 'Default',
'product_type' => 'configurable',
'product_websites' => 'base',
'name' => 'FireGento Test Product Configurable',
'price' => '10.000',
'configurable_variation_labels' => 'Color'
'configurable_variation_labels' => 'Color',
'configurable_variations' => array(
array(
'sku' => 'SIMPLE-BLUE-SMALL',
'color' => 'blue',
'size' => 'S'),
array(
'sku' => 'SIMPLE-RED-MIDDLE',
'color' => 'red',
'size' => 'M'),
)

);

$colors = array("blue", "black");
$variationsString = '';
for ($i = 0; $i < 2; $i++) {

$color = $colors[$i];
$sku = 'SIMPLE-' . $color;
$simpleProducts[] = array(
'sku' => $sku,
'attribute_set_code' => 'Default',
'product_type' => 'simple',
'product_websites' => 'base',
'name' => 'FireGento Test Product Simple - ' . $color,
'price' => '14.0000',
'additional_attributes' => array('color' => $color)

);
$variationsString[] = array('sku' => $sku, 'color' => $color);
}
$configurableProduct["configurable_variations"] = $variationsString;


$data = array_merge($simpleProducts, array($configurableProduct));


return $data;
return $products;
}
}
88 changes: 88 additions & 0 deletions Console/Command/Product/ImportCsv.php
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);
}
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Installation Instructions with Composer(Master Branch)
### Delete all products in Catalog(Warning : really all Products):
`bin/magento fastsimpleimportdemo:products:deleteall`

### Import products from CSV File:
`bin/magento fastsimpleimportdemo:products:importcsv`

## Customers

Expand All @@ -50,6 +52,8 @@ Installation Instructions with Composer(Master Branch)
### Delete all customers:
`bin/magento fastsimpleimportdemo:customers:deleteall`

### Import Categorys(BETA,work in Progress):
## Categories

### Import Categories:
`bin/magento fastsimpleimportdemo:category:import`

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"homepage": "https://github.com/magento-hackathon/FireGento_FastSimpleImport2_Demo",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0",
"firegento/fastsimpleimport": "*"
"firegento/fastsimpleimport": "*",
"league/csv": "^8.0"
},
"type": "magento2-module",
"license": "GPL-3.0",
Expand Down
7 changes: 7 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@
<item name="import_simple" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Product\ImportSimple</item>
<item name="import_bundle" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Product\ImportBundle</item>
<item name="import_multiselect" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Product\ImportMultiselect</item>
<item name="import_csv" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Product\ImportCsv</item>

<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_multi" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Category\ImportCategoryMultiStoreView</item>


<item name="export_products" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Product\ExportProducts</item>
<item name="export_orders" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Orders\ExportOrders</item>
<item name="export_customers" xsi:type="object">FireGento\FastSimpleImportDemo\Console\Command\Customer\ExportCustomer</item>


</argument>
</arguments>
Expand Down

0 comments on commit 3b127fd

Please sign in to comment.