Importing CSV

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
swpierce
Posts: 53
Joined: 01 Nov 2015, 13:19

Importing CSV

Post by swpierce » 28 Nov 2015, 05:32

I'm trying to import some products via csv. I am running up against an error and I cannot figure out the issue. Maybe someone can spot what I'm doing wrong?

My mapping (not all of it but the relevant parts....I think) :

Code: Select all

                        'mapping' => array(
                            'item' => array(
                                0 => 'product.code', 
                                1 => 'product.label',
                                2 => 'product.type',
                                3 => 'product.status',
                            ),
                            'text' => array(
                                4 => 'text.type',
                                5 => 'text.content',
                                6 => 'text.type',
                                7 => 'text.content',
                            ),
                            'media' => array(
                                8 => 'media.url',
                                9 => 'media.preview',
                            ),
                            'price' => array(
                                10 => 'price.value',
                            ),
                            'property' => array(
                                11 => 'product.property.type',
                                12 => 'product.property.value',
                            ),
                            'catalog' => array(
                                13 => 'catalog.code',
                                14 => 'catalog.code',
                                15 => 'catalog.code',
                            ),
                            'attribute' => array(
                                16 => 'attribute.type',
                                17 => 'attribute.code',
                                18 => 'attribute.type',
                                19 => 'attribute.code',
                                20 => 'attribute.type',
My csv file:

Code: Select all

"product1","Product 1 Label","default","1","short","Product 1 Short Desc","long","Product 1 Long Desc","prod1.png","prod1-sm.jpg","1.95","package-weight","0.5","home","category1","subcategory1",,"color","color-orange","color","color-green","color","color-yellow","color","color-brown","season","season-fall","event","holiday-thanksgiving","month","month-nov","style","style-cute",,
Whenever I run the import, I get the following error:

Code: Select all

Undefined index: attribute.code
What am I overlooking?

User avatar
aimeos
Administrator
Posts: 7865
Joined: 01 Jan 1970, 00:00

Re: Importing CSV

Post by aimeos » 28 Nov 2015, 10:21

The shown mapping looks OK and the problem might be in the rest of the attribute mapping. Can you post the complete attribute part?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swpierce
Posts: 53
Joined: 01 Nov 2015, 13:19

Re: Importing CSV

Post by swpierce » 28 Nov 2015, 13:38

Here is the entire mapping:

Code: Select all

                        'mapping' => array(
                            'item' => array(
                                0 => 'product.code', 
                                1 => 'product.label',
                                2 => 'product.type',
                                3 => 'product.status',
                            ),
                            'text' => array(
                                4 => 'text.type',
                                5 => 'text.content',
                                6 => 'text.type',
                                7 => 'text.content',
                            ),
                            'media' => array(
                                8 => 'media.url',
                                9 => 'media.preview',
                            ),
                            'price' => array(
                                10 => 'price.value',
                            ),
                            'property' => array(
                                11 => 'product.property.type',
                                12 => 'product.property.value',
                            ),
                            'catalog' => array(
                                13 => 'catalog.code',
                                14 => 'catalog.code',
                                15 => 'catalog.code',
                                16 => 'catalog.code',
                                17 => 'catalog.code',
                                18 => 'catalog.code',
                                19 => 'catalog.code',
                                20 => 'catalog.code',
                                21 => 'catalog.code',
                            ),
                            'attribute' => array(
                                22 => 'attribute.type',
                                23 => 'attribute.code',
                                24 => 'attribute.type',
                                25 => 'attribute.code',
                                26 => 'attribute.type',
                                27 => 'attribute.code',
                                28 => 'attribute.type',
                                29 => 'attribute.code',
                                30 => 'attribute.type',
                                31 => 'attribute.code',
                                32 => 'attribute.type',
                                33 => 'attribute.code',
                                34 => 'attribute.type',
                                35 => 'attribute.code',
                                36 => 'attribute.type',
                                37 => 'attribute.code',
                                38 => 'attribute.type',
                                39 => 'attribute.code',
                                40 => 'attribute.type',
                                41 => 'attribute.code',
                                42 => 'attribute.type',
                                43 => 'attribute.code',
                                44 => 'attribute.type',
                                45 => 'attribute.code',
                                46 => 'attribute.type',
                                47 => 'attribute.code',
                                48 => 'attribute.type',
                                49 => 'attribute.code',
                                50 => 'attribute.type',
                                51 => 'attribute.code',
                                52 => 'attribute.type',
                                53 => 'attribute.code',
                                54 => 'attribute.type',
                                55 => 'attribute.code',
                                55 => 'attribute.type',
                                56 => 'attribute.code',
                                57 => 'attribute.type',
                                58 => 'attribute.code',
                                59 => 'attribute.type',
                                60 => 'attribute.code',
                                61 => 'attribute.type',
                                62 => 'attribute.code',
                                63 => 'attribute.type',
                                64 => 'attribute.code',
                                65 => 'attribute.type',
                                66 => 'attribute.code',
                                67 => 'attribute.type',
                                68 => 'attribute.code'
                            ),
                        ),
and here is the entire CSV line:

Code: Select all

"product1_fb","Product1 Label","default","1","short","1 package of Product1","long","1 package of Product1 widgets (4 widgets).<br><br>Each widget:<br><ul><li>Measures 1.5"" x 1.9""</li><li>Solves all your life's problems</li><li>Is made by WidgetCo&trade;</li></ul>The Product1 collection is based on 4 coordinated widgety-type patterns.<br><br><font size=""1"">We are not associated with WidgetCo&trade;</font>","product1/prod1.png","product1/previews/prod1.jpg","1.95","package-weight","0.5","home","widgets","trinkets",,,,,,,"color","color-oranges","color","color-yellows","color","color-Greens","color","color-brown","season","season-fall","event","event-harvest","month","month-sep","month","month-oct","month","month-nov","theme","theme-food","pattern","pattern-floral","pattern","pattern-foliage","style","style-country",,,,,,,,,,,,,,,,,,,,,

User avatar
aimeos
Administrator
Posts: 7865
Joined: 01 Jan 1970, 00:00

Re: Importing CSV

Post by aimeos » 28 Nov 2015, 14:43

Hm, maybe there's a problem with the number of columns in the CSV file. The mapping is OK as far as I can see. I hope the CSV isn't parsed wrong due to your HTML text ...
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swpierce
Posts: 53
Joined: 01 Nov 2015, 13:19

Re: Importing CSV

Post by swpierce » 28 Nov 2015, 15:42

I hope so too. The HTML is exactly the same as Aimeos stores it in the database.

I've loaded the CSV into OpenOffice and added a field-number row at the top. The fields match up exactly to the mapping. I even sat and counted the fields in the CSV by hand to double-check.

I don't think it's a field count thing because I can arbitrarily add fields here and there and the import always fails with the exact same error message.

If it is an HTML-related issue, how do we import formatted text into the long description? Importing unformatted text and then having to touch every single item in the Aimeos admin interface in order to format it after the fact pretty much defeats the whole purpose of importing in the first place, right?

swpierce
Posts: 53
Joined: 01 Nov 2015, 13:19

Re: Importing CSV [SOLVED]

Post by swpierce » 28 Nov 2015, 17:33

If anyone has this same problem, here's the issue:

No trailing commas! If the fields at the end are blank, just strip all the trailing commas and the processor figures it all out. Import crashes every time I leave any trailing commas in the file.

Also, if you ever get an error that says

Code: Select all

Undefined index: attribute.code
the problem is not necessarily with the format of your import file or your mapping. It's likely your data. I had a typo in on the attribute.code values in the import file and the import kept crashing because it couldn't find that particular attribute code in the database. When I fixed the typo, import ran fine.

User avatar
aimeos
Administrator
Posts: 7865
Joined: 01 Jan 1970, 00:00

Re: Importing CSV [SOLVED]

Post by aimeos » 30 Nov 2015, 13:28

We've fixed that in the latest code at it will be part of the next release.
Thanks for the hint :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply