phpcommand-linecsv-importakeneopim

Akeneo add filepath parameter using csv import from commandline


I am trying to run an standard csv import from commandline. Everything works fine when working from UI, but for developers reasons I want to trigger it from commandline.

I can trigger the import job like this:

php bin/console akeneo:batch:job csv_import

But I get this error:

Job instance "csv_import" running the job "csv_attribute_import" with parameters "Array  
  (                                                                                        
      [filePath] =>                                                                        
      [delimiter] => ;                                                                     
      [enclosure] => "                                                                     
      [escape] => \                                                                        
      [withHeader] => 1                                                                    
      [uploadAllowed] => 1                                                                 
      [invalid_items_file_format] => csv                                                   
      [user_to_notify] =>                                                                  
      [is_user_authenticated] =>                                                           
  )                                                                                        
  " is invalid because of "                                                                
    - Array[filePath]:                                                                     
      This value should not be blank. (code c1051bb4-d103-4f74-8988-acbcafc7fdc3)"

Which makes sense since I did not pass any filepath as parameter, how can I do this?


Solution

  • Found it!

    php bin/console akeneo:batch:job -c "{\"filePath\":\"/tmp/foo.csv\"}" acme_product_import)
    

    Found the example code in the following file line 57 (Akeneo 3.2):

    vendor/akeneo/pim-community-dev/src/Akeneo/Bundle/BatchBundle/Command/BatchCommand.php