Is there an extension or app or a way to import products from a CSV file?
#53 Import - export
This is a public ticket
Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Latest post by Olivier on Thursday, 05 December 2024 14:57 UTC
Friday, 29 November 2024 19:47 UTC
Saturday, 30 November 2024 01:51 UTC
Hello!
We do have a plugin available for simple CSV import, it still needs a bit of a cleanup before we can offer it in the repository.
You can find more information at https://docs.j2commerce.com/j2commerce/apps/simple-csv-import-and-export.
You may also want to look at https://extensions.joomla.org/extension/ro-csvi/ for more advanced features.
Olivier.
Sunday, 01 December 2024 05:49 UTC
Hello :-)
We released the Simple CSV import/export app. You can try it out (download from our store).
Olivier.
Sunday, 01 December 2024 13:48 UTC
Thanks Oliver,
The plugin requires a license key. Where do i find that?
Sunday, 01 December 2024 15:25 UTC
Oliver,
I tried this and got this error:
Error inserting remaining products: Incorrect datetime value: '12/1/2024 14:26' for column `ecopetsu_store`.`ep_content`.`created` at row 1
Here is whjat I did-
First I created a product in J2Store. A basic simple test product, filled in all of the fields as appropriate for this simple product.
Then I used the plugin to export is to a csv file. The file appears to have all of the fields as shown in the docs.
Then I deleted that product and used the plugin to import that csv file. I set the characterf set to UTF-8 as my database is utf8mb4_general_ci
When I look at the database column as shown in the error above, that column has the datetime format of "2021-05-13 02:12:05". MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format.
It appears as though the plugin is trying to write the product content with a datetime format of "MM/DD/YYYY hh:mm" and the import fails.
In the CSV the column 'created_on" has the dated as 12/1/2024 14:26. All other Joomla content in that table use the datetime format of YYYY-MM-DD hh:mm:ss.
So it appears that the plugin is creating the datetime format incorrectly on an export. Once I changed the format of the cells in the CSV to the correct datetime it imported the product.
There were a couple of other errors that I think were in the csv file but I'm not sure where they came from. If I figure that out I will update this.
Sunday, 01 December 2024 19:05 UTC
Hello,
I have not encountered those issues during my testing, so I was wondering:
- was the store migrated from an earlier version of Joomla (2.5 or 3)?
- all dates (created_on for instance) on exports I have done have the correct format. Have you checked the created_on date in the database (that would be the j2store_products table)?
Could send us a line of data you have created on export? I will probably have to add new code to account for dates that may be mal-formed and null dates (dates are null now in Joomla 4 rather than 0000-00-00 00:00:00).
Thank you!
Olivier.
Sunday, 01 December 2024 19:40 UTC
No migration. your version of J2store, downloaded here, was what was installed and the Joomla version is 5.2.2
I have attached the export file I created it is just one product. I created it a a simple product. It is possible that the csv file that I opend with Excel set the cell format for dates incorrectly and that caused the problem, but I have no othe way of opening a csv to tell for sure.
I made the corrections and saved it to another fle name and that was able to be imported, but still caused a couple of errors I can't explain. I uploaded it as will, j2test.csv
Sunday, 01 December 2024 19:48 UTC
I just looked at the 1st csv file in Notepad++ and it has the dates formated as 12/0/2024 14:26. So it appears the plugin IS setting the date in that format.
Sunday, 01 December 2024 20:18 UTC
Thanks for the sample files. ALL you dates are truncated, not just one apparently.
I will dive into the code to see what is going on. Note that ALL the dates in my export files are correct so the plugin may not be the cause. Have you been able to check the database? Or could you give us access to it? Thank you!
You mentioned other errors. Can you let me know what they are?
Olivier.
Sunday, 01 December 2024 20:53 UTC
All of the normal joomla dates in the content table are set to the yyyy-mm-dd format by MySql. The site I am working on is a new quickstart with T4 BS5 templates. But that makes no difference to the content table. That is created by a joomla install and any articles created will be that format.
Yes the dates were set in the CSV file when it was exported, so those would have to be by the plugin as the other articles content is created correctly in the database. The j2test.csv file was after I corrected the date format on all of the date cells in Excel, It was THAT file I used for the import. The first one was what the plugin created and that was what failed.
I can't give server access aa there are other files there with confidential info. I can export content from any table you want as a csv file if that would help.
The other "errors" may have been data that the import did not recognize, so it may be more of a notice of data error rather than a coding error
Monday, 02 December 2024 01:08 UTC
Thanks for the information.
I checked the code and at first glance, I did not spot any modification of the dates, the data is exported 'as-is'.
Thanks for checking the database. I was not wondering about the content table, though, but about the j2store_products table.
This is the data I receive, when exporting on a test site, no editing to it:
...
"13","1","com_content","22","simple","","0","0","0","","","1","","2024-11-25 22:49:52","75","","","","","","","","images/no-photo-86x110.jpg#joomlaImage://local-images/no-photo-86x110.jpg?width=86&height=110","","","[""""]","0","My product Imported","my-product-imported","","","1","12","2024-10-21 22:02:22","","2024-11-26 04:17:53","","","2024-11-24 01:20:18","",
...
Now, we have to find out why I am getting a correct output on my test site, and not on your site.
No seeing the whole picture makes it difficult to figure out. Can you send me one line export from the j2store_products and j2store_variants tables (or screenshots that show the data, the dates in particular)?
Thank you!
Olivier.
Monday, 02 December 2024 14:51 UTC
Oliver, there are only 2 entries in those tables so the exports are attaced as csv files.
I also did another product export using the plugin and it is attached as well. If I open that with Notepad, the dates are correct. But if it is opened with Excel, then the dates are converted to the MM/DD/YYYY format by Excel. So the problem is in how Excel handles that. Since Excel would be the program that users would use to work with these files and the dates would then be saved incorrectly after edits, it might be necessary to clarify that in the docs or maybe refer to this link for clarification:
I applied these changes to my computer and now the csv opens with the dates correct. However, the settings in my region are accepted for the USA. That is the default settings when Windows is installed on my computer. I can see that this could cause problems in other locales that may use the MM/DD/YYYY format on their systems, I am at a loss as to how to handle that, but an explanation in the docs would be a good place to start
Monday, 02 December 2024 15:02 UTC
Oliver,
I have done a littel more research and given this more thought. Since Excel will probably be the way users will edit the csv files and since Excel defaults to the MM/DD/YYYY format AND changing the REGION settings on their computer can have a broad affect of other applications, that would nopt be the best solution. I think it would be better to have the plugin parse the csv during import for the dates and convert them all to the YYYY/MM/DD. Asking users to either change their personal region settings might create bigger problems for them, or adviseing them to alter all the date formats in thier CSV import file that might contain hundreds of entries would be very tedious. A coding solution would be a better solution.
Monday, 02 December 2024 21:08 UTC
Hello,
I can see what the problem is, but date format needs to remain the same, it is the way it is stored in the database by Joomla, no matter what region a person is from. And the import won't work unless it remains that way.
An improvement to the app could be to use the timezone site configuration information to import/export data. Dates would be set the the right time zone.
An additional field could be a date format. So that the app would know what to convert the dates back from, since they need to end up as something like 2024-11-24 01:20:18 into the database.
As far as the documentation is concerned, please be patient as we took over the extension about a month ago and are trying to tackle all user needs as humanly as possible.
Thank you for all the feedback and tests.
Olivier.
Monday, 02 December 2024 23:24 UTC
Oliver,
What I suggested was not to change the dattime format theat Joomla and MySql uses. I kjnow It has to be that way. It is not wise to have users change the region in the computers to solve the problem eiother as that would create a lot of unintended consequences elsewhere. What I suggest is for the import routine to check the csv import for the MM/DD/YYYY format that might be there because the user used Excel to edit the file and then saved it with that format in those cells. Then if the import enccounters the format, it just converts it back to the proper format so the error does not occur.
I realize that ytou guys just got into aal this recently and I appreciate your efforts so far. If I can help you make it better, please let me know. I am happy to test things for you.
A suggestion for this plugin, in the future, would be a way to map fields into the J2Store database from a CSV file that was exported from some other ecommerce platfom. The users from other ecommerc apps would have an easier time migrating to J2Commerce.
Monday, 02 December 2024 23:36 UTC
I understand you did not suggest the change in the database tables :-)
I am adding a new field for the format the user wants to use when importing. It will convert the dates to the right format back into the databse and prevent errors.
As far as the suggestion for mapping from another ecommerce platform, Roland's extension (https://extensions.joomla.org/extension/ro-csvi/) does just that. You can export data from Virtuemart, for instance, and re-inject the data into J2Commerce.
Thanks!
Olivier.
Thursday, 05 December 2024 14:57 UTC
Hello!
I wanted to touch base with you to give you a quick update on the import/export tool.
I have improved the app and it can now take any format for the date when importing. You will just have to make sure you specify the format beforehand. The system will do the rest and put those dates back in the database properly.
While testing, I noticed another major issue (articles do not show in the Content component, even though they are present in the database). That is a side effect from changes made in Joomla 4. So, I am looking into that right now.
Olivier.
Stay Updated
Subscribe for free and be the first to know about the latest features, updates, and new additions.