Skip to content

Commit

Permalink
Merge pull request #10 from wagnert/master
Browse files Browse the repository at this point in the history
Switch to new create/delete naming convention + Add basic product update functionality for add-update operation
  • Loading branch information
wagnert authored Dec 23, 2016
2 parents 0e9fe5f + 70a1468 commit 30c79d3
Show file tree
Hide file tree
Showing 14 changed files with 791 additions and 222 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Version 1.0.0-alpha8

## Bugfixes

* None

## Features

* Switch to new create/delete naming convention
* Add basic product update functionality for add-update operation

# Version 1.0.0-alpha7

## Bugfixes
Expand Down
66 changes: 57 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Installation

To install the Magnento 2 Import Framework, composer is necessary. The framework itself is a set of components
that provide import functionality for Magento 2. The package `techdivision/import-cli-simple`, based on Symfony
Console, uses de M2IF and provides a command line tool with import functionality for Magento 2 standard CSV
files.
To install the Magnento 2 Import Framework, composer is necessary. The framework itself is a set of components
that provide import functionality for Magento 2. This repository, based on Symfony Console, uses the the package
[M2IF](https://github.com/techdivision/import) and provides a command line tool with import functionality for
Magento 2 standard CSV files.

To install the package, assuming composer is available, open a console and enter

Expand All @@ -23,7 +23,7 @@ sample data in a Magento 2 CE version 2.1.2 can be found in `example/ce/212/conf
The configuration file (option `--configuration`) **MUST** to be specified whenever data has to be imported,
as it contains the operations, subjects and callbacks configuration.

The import command allows arguments (actually only one) as well as options.
The import command itself supports a argument as well as several options.

### Arguments

Expand Down Expand Up @@ -72,6 +72,49 @@ for the available operations.
}
```

The operations are simply a container, that allows to have a custom subject configuration for each operation.
This makes sense, as the `delete` operation only needs the `ClearProductObserver`, that removes the product
with the SKU found in each row of the CSV file as well as all it's relations. The `delete` operation therefore
is small a configuration variation out of the available subjects, observers and callbacks and looks like this

```json
{
"magento-edition": "CE",
"magento-version": "2.1.2",
"operation-name" : "replace",
"installation-dir" : "/var/www/magento",
"utility-class-name" : "TechDivision\\Import\\Utils\\SqlStatements",
"database" : { ... },
"operations" : [
{
"name" : "delete",
"subjects" : [
{
"class-name": "TechDivision\\Import\\Product\\Ee\\Subjects\\EeBunchSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\EeProductBunchProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Ee\\Utils\\SqlStatements",
"identifier": "files",
"source-date-format": "n/d/y, g:i A",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"prefix": "magento-import",
"observers": [
{
"import": [
"TechDivision\\Import\\Product\\Observers\\ClearProductObserver"
]
}
]
}
]
}
]
}
```

Most of the available configuration options can be specified on the subjects itself, which are nested under the
operations.

## Operations

As well as the Magento 2 standard import functionality, M2IF will provide 3 different import operations:
Expand Down Expand Up @@ -99,9 +142,11 @@ on the command line.
## Running the Import

The command doesn't implement any directory clean-up or archiving functionality, what means that the files
have to copied to the source directory specified for the subjects. When running the example, this will be
`example/tmp`. To make sure, that all old import files will be removed, we'll delete and re-create the
directory before.
have to copied to the source directory specified for the subjects. Assuming a Magento 2 CE 2.1.2 instance,
with sample data installed, is available under `/var/www/magento` the configuration file, as well as the
CSV files, can be found under `projects/sample-data/ce/212`.

The command to re-import the sample data including the images, would look like this:

```sh
$ sudo rm -rf projects/sample-data/tmp \
Expand All @@ -110,4 +155,7 @@ $ sudo rm -rf projects/sample-data/tmp \
&& sudo bin/import-simple import:products \
--installation-dir=/var/www/magento \
--configuration=projects/sample-data/ce/212/conf/techdivision-import.json
```
```

To make sure, that all old import files will be removed, we'll delete and re-create the directory that contains
the import files `projects/sample-data/tmp`, before.
Binary file removed projects/.DS_Store
Binary file not shown.
Binary file removed projects/sample-data/.DS_Store
Binary file not shown.
248 changes: 248 additions & 0 deletions projects/sample-data/ce/212/conf/techdivision-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,254 @@
]
}
]
},
{
"name" : "add-update",
"subjects": [
{
"class-name": "TechDivision\\Import\\Product\\Subjects\\BunchSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\ProductBunchProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Utils\\SqlStatements",
"identifier": "files",
"source-date-format": "n/d/y, g:i A",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"prefix": "magento-import",
"observers": [
{
"pre-import": [
"TechDivision\\Import\\Product\\Observers\\AdditionalAttributeObserver",
"TechDivision\\Import\\Product\\Observers\\QuantityAndStockStatusObserver"
]
},
{
"import": [
"TechDivision\\Import\\Product\\Observers\\ProductUpdateObserver",
"TechDivision\\Import\\Product\\Observers\\ProductWebsiteObserver",
"TechDivision\\Import\\Product\\Observers\\ProductCategoryObserver",
"TechDivision\\Import\\Product\\Observers\\ProductInventoryObserver",
"TechDivision\\Import\\Product\\Observers\\UrlRewriteObserver",
"TechDivision\\Import\\Product\\Observers\\ProductAttributeObserver",
"TechDivision\\Import\\Product\\Variant\\Observers\\ProductVariantObserver",
"TechDivision\\Import\\Product\\Bundle\\Observers\\ProductBundleObserver",
"TechDivision\\Import\\Product\\Media\\Observers\\ProductMediaObserver",
"TechDivision\\Import\\Product\\Link\\Observers\\ProductLinkObserver"
]
},
{
"post-import": [
"TechDivision\\Import\\Product\\Observers\\CleanUpObserver"
]
}
],
"callbacks": [
{
"visibility": [
"TechDivision\\Import\\Product\\Callbacks\\VisibilityCallback"
]
},
{
"tax_class_name": [
"TechDivision\\Import\\Product\\Callbacks\\TaxClassCallback"
]
},
{
"bundle_price_type": [
"TechDivision\\Import\\Product\\Bundle\\Callbacks\\BundleTypeCallback"
]
},
{
"bundle_sku_type": [
"TechDivision\\Import\\Product\\Bundle\\Callbacks\\BundleTypeCallback"
]
},
{
"bundle_weight_type": [
"TechDivision\\Import\\Product\\Bundle\\Callbacks\\BundleTypeCallback"
]
},
{
"bundle_price_view": [
"TechDivision\\Import\\Product\\Bundle\\Callbacks\\BundlePriceViewCallback"
]
},
{
"eco_collection": [
"TechDivision\\Import\\Product\\Callbacks\\BooleanCallback"
]
},
{
"performance_fabric": [
"TechDivision\\Import\\Product\\Callbacks\\BooleanCallback"
]
},
{
"erin_recommends": [
"TechDivision\\Import\\Product\\Callbacks\\BooleanCallback"
]
},
{
"new": [
"TechDivision\\Import\\Product\\Callbacks\\BooleanCallback"
]
},
{
"sale": [
"TechDivision\\Import\\Product\\Callbacks\\BooleanCallback"
]
},
{
"activity": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"style_bags": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"material": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"strap_bags": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"features_bags": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"gender": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"category_gear": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"style_bottom": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"style_general": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"sleeve": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"collar": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"pattern": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"climate": [
"TechDivision\\Import\\Product\\Callbacks\\MultiselectCallback"
]
},
{
"size": [
"TechDivision\\Import\\Product\\Callbacks\\SelectCallback"
]
},
{
"color": [
"TechDivision\\Import\\Product\\Callbacks\\SelectCallback"
]
}
]
},
{
"class-name": "TechDivision\\Import\\Product\\Variant\\Subjects\\VariantSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\ProductVariantProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Variant\\Utils\\SqlStatements",
"prefix": "variants",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"observers": [
{
"import": [
"TechDivision\\Import\\Product\\Variant\\Observers\\VariantObserver"
]
}
]
},
{
"class-name": "TechDivision\\Import\\Product\\Bundle\\Subjects\\BundleSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\ProductBundleProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Bundle\\Utils\\SqlStatements",
"prefix": "bundles",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"observers": [
{
"import": [
"TechDivision\\Import\\Product\\Bundle\\Observers\\BundleOptionObserver",
"TechDivision\\Import\\Product\\Bundle\\Observers\\BundleOptionValueObserver",
"TechDivision\\Import\\Product\\Bundle\\Observers\\BundleSelectionObserver",
"TechDivision\\Import\\Product\\Bundle\\Observers\\BundleSelectionPriceObserver"
]
}
]
},
{
"class-name": "TechDivision\\Import\\Product\\Media\\Subjects\\MediaSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\ProductMediaProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Media\\Utils\\SqlStatements",
"prefix": "media",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"params" : [
{
"root-directory" : "/",
"media-directory" : "/opt/appserver/webapps/magento2_ce212/pub/media/catalog/product",
"images-file-directory" : "projects/sample-data/magento2-sample-data/pub/media/catalog/product"
}
],
"observers": [
{
"pre-import" : [
"TechDivision\\Import\\Product\\Media\\Observers\\FileUploadObserver"
],
"import": [
"TechDivision\\Import\\Product\\Media\\Observers\\MediaGalleryObserver",
"TechDivision\\Import\\Product\\Media\\Observers\\MediaGalleryValueObserver"
]
}
]
},
{
"class-name": "TechDivision\\Import\\Product\\Link\\Subjects\\LinkSubject",
"processor-factory" : "TechDivision\\Import\\Cli\\Services\\ProductLinkProcessorFactory",
"utility-class-name" : "TechDivision\\Import\\Product\\Links\\Utils\\SqlStatements",
"prefix": "links",
"source-dir": "projects/sample-data/tmp",
"target-dir": "projects/sample-data/tmp",
"observers": [
{
"import": [
"TechDivision\\Import\\Product\\Link\\Observers\\LinkObserver"
]
}
]
}
]
}
]
}
Binary file removed projects/sample-data/ee/.DS_Store
Binary file not shown.
Binary file removed projects/sample-data/ee/212/.DS_Store
Binary file not shown.
Loading

0 comments on commit 30c79d3

Please sign in to comment.