3

is it possible to import csv in Magento 2 from ssh command?

  • even i want to know is there any option in magento 1 – Baby in Magento Apr 11 '16 at 13:42
  • you can use magmi – Gennaro Santoro May 17 '16 at 1:59
3

If you look at the list of bin/magento commands, there is no one to trigger the CSV import. As all shell commands in Magento 2 are executed with bin/magento, the answer is no.

| improve this answer | |
0

You could add your own command in magento 2 and mimic what happens in magento's backend.

I did it this way and it works well.

Take a look at magento/module-import-export/Controller/Adminhtml/Import/Validate.php

for the validation part and

magento/module-import-export/Controller/Adminhtml/Import/Start.php

for the consumer.

In order to initalize the importer you have to pass some configuration data.

Here's an example:

[
        "entity"                    => "catalog_product",
        "behavior"                  => "append",
        "validation_strategy"       => "validation-stop-on-errors",
        "allowed_error_count"       => 10,
        "_import_field_separator"   => ",",
        "_import_multiple_value_separator" => ",",
        "import_images_file_dir"    => ""
    ]

I hope this gives you a good starting point.

Michele

| improve this answer | |
0

There is a module with which you can integrate a corresponding shell command: https://github.com/cedricblondeau/magento2-module-catalog-import-command

You can simply install it with composer and enable it like this:

composer require cedricblondeau/magento2-module-catalog-import-command
php bin/magento module:enable CedricBlondeau_CatalogImportCommand
php bin/magento setup:upgrade

Usage is pretty straigth forward:

php bin/magento catalog:import -i pub/media/import -b add_update catalogdata.csv

where catalogdata.csv is in your magento webroot directory and -i designates the directory where your images are stored.

It's still working well with Magento 2.3.2. I've been using it since ver. 2.2.2, hope it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.