Import products with images from CSV
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 2
- Joined: 23 Oct 2019, 16:01
Import products with images from CSV
I try to import products from a CSV file on my local Mac using the instructions and example from
https://aimeos.org/docs/Developers/Cont ... s_from_CSV
My problem is that products are uploaded but no images and I get some error messages I can't understand.
I did minor changes in products-import-example.csv adding media.preview beside the media.url, not sure if I need both though.
My configuration looks like this:
The images (image.jpg and image2.jpg) are placed in /Users/myuser/dev/AimeosEXP/import/media.
I run the import using the command php artisan aimeos:jobs product/import/csv
Executing the Aimeos job gives me some errors that I can't solve.
Invalid product lines in "/Users/myuser/dev/AimeosEXP/import": 1/4#0 /Users/myuser/dev/AimeosEXP/vendor/aimeos/aimeos-laravel/src/Aimeos/Shop/Command/JobsCommand.php(69): Aimeos\Controller\Jobs\Product\Import\Csv\Standard->run()
...
#23 {main}Process (PID "9350") failed with status "256"iMac:AimeosEXP myuser$
Three products are uploaded to Aimeos. job_csv_test, job_csv_test2 and one empty product. No images!
The Aimeos log shows some additional error messages:
Finished product import from "/Users/myuser/dev/AimeosEXP/import": 3 successful, 1 errors, 4 total (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from "product-import-example.csv": 2/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from ".DS_Store.csv": 1/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Started product import from "/Users/myuser/dev/AimeosEXP/import" (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Finished product import from "/Users/myuser/dev/AimeosEXP/import": 3 successful, 1 errors, 4 total (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from "product-import-example.csv": 2/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from ".DS_Store.csv": 1/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Started product import from "/Users/myuser/dev/AimeosEXP/import"
Unable to import product with code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400": Code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400" must not be longer than 64 characters
Unable to import product with code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400": Code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400" must not be longer than 64 characters
I don't know if the problems are caused by the CSV file or something else?
https://aimeos.org/docs/Developers/Cont ... s_from_CSV
My problem is that products are uploaded but no images and I get some error messages I can't understand.
I did minor changes in products-import-example.csv adding media.preview beside the media.url, not sure if I need both though.
Code: Select all
"item code","item label","item type","item status","text type","text content","text type","text content","media preview","media url","price currencyid","price quantity","price value","price tax rate","attribute code","attribute type","subproduct code","product list type","property value","property type","catalog code","catalog list type"
"job_csv_test","job csv test product","default",1,"short","short description","long","long description","media/image.jpg","media/image.jpg","EUR",1,"11.00","20.00","import-test","size",,,"1.50","package-weight","home","promotion"
"job_csv_test2","job csv test 2. product","select",1,"short","short selection description","long","long selection description","media/image2.jpg","media/image2.jpg","EUR",1,"10.00","20.00",,,"job_csv_test","default","1.50","package-weight","home","default"
Code: Select all
'client' => [
'html' => [
'common' => [
'content' => [
'baseurl' => '/Users/myuser/dev/AimeosEXP/import',
...
'controller' => [
'common' => [
'product' => [
'import' => [
'csv' => [
'mapping' => [
'item' => [
0 => 'product.code', // e.g. unique EAN code
1 => 'product.label', // UTF-8 encoded text, also used as product name
2 => 'product.type', // type of the product, e.g. "default" or "selection"
3 => 'product.status', // enabled (1) or disabled (0)
],
'text' => [
4 => 'text.type', // e.g. "short" for short description
5 => 'text.content', // UTF-8 encoded text
6 => 'text.type', // e.g. "long" for long description
7 => 'text.content', // UTF-8 encoded text
],
'media' => [
8 => 'media.preview', // relative URL of the product image on the server
9 => 'media.url', // relative URL of the product image on the server
],
'price' => [
10 => 'price.currencyid', // three letter ISO currency code
11 => 'price.quantity', // the quantity the price (for block pricing)
12 => 'price.value', // price with decimals separated by a dot
13 => 'price.taxrate', // tax rate with decimals separated by a dot
],
'attribute' => [
14 => 'attribute.code', // code of an attribute, will be created if not exists
15 => 'attribute.type', // e.g. "size", "length", "width", "color", etc.
],
'product' => [
16 => 'product.code', // e.g. EAN code of another product
17 => 'product.lists.type', // e.g. "suggestion" for suggested product
],
'property' => [
18 => 'product.property.value', // arbitrary value for the corresponding type
19 => 'product.property.type', // e.g. "package-weight"
],
'catalog' => [
20 => 'catalog.code', // e.g. Unique category code
21 => 'catalog.lists.type', // e.g. "promotion" for top seller products
],
],
],
],
],
],
'jobs' => [
'product' => [
'import' => [
'csv' => [
'location' => '/Users/myuser/dev/AimeosEXP/import',
'skip-lines' => 1,
],
],
],
],
],
I run the import using the command php artisan aimeos:jobs product/import/csv
Executing the Aimeos job gives me some errors that I can't solve.
Invalid product lines in "/Users/myuser/dev/AimeosEXP/import": 1/4#0 /Users/myuser/dev/AimeosEXP/vendor/aimeos/aimeos-laravel/src/Aimeos/Shop/Command/JobsCommand.php(69): Aimeos\Controller\Jobs\Product\Import\Csv\Standard->run()
...
#23 {main}Process (PID "9350") failed with status "256"iMac:AimeosEXP myuser$
Three products are uploaded to Aimeos. job_csv_test, job_csv_test2 and one empty product. No images!
The Aimeos log shows some additional error messages:
Finished product import from "/Users/myuser/dev/AimeosEXP/import": 3 successful, 1 errors, 4 total (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from "product-import-example.csv": 2/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from ".DS_Store.csv": 1/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Started product import from "/Users/myuser/dev/AimeosEXP/import" (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Finished product import from "/Users/myuser/dev/AimeosEXP/import": 3 successful, 1 errors, 4 total (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from "product-import-example.csv": 2/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Imported product lines from ".DS_Store.csv": 1/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Started product import from "/Users/myuser/dev/AimeosEXP/import"
Unable to import product with code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400": Code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400" must not be longer than 64 characters
Unable to import product with code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400": Code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400" must not be longer than 64 characters
I don't know if the problems are caused by the CSV file or something else?
Aimeos 2019.10
Laravel 6.3
PHP 7.3.9
macOS 10.14.6 - Laravel Valet
Laravel 6.3
PHP 7.3.9
macOS 10.14.6 - Laravel Valet
Re: Import products with images from CSV
No, preview images are generated automatically, so you don't need them in your file.lighthouse wrote: ↑23 Oct 2019, 18:14 I did minor changes in products-import-example.csv adding media.preview beside the media.url, not sure if I need both though.
They can't be found because the default configuration expects them in a directory in the ./public/ directory. Put them into ./public/media/ and they should be available in the frontend and backend. If you use "./artisan serve", then make sure that your .env file contains "APP_URL=http://localhost:8000"lighthouse wrote: ↑23 Oct 2019, 18:14The images (image.jpg and image2.jpg) are placed in /Users/myuser/dev/AimeosEXP/import/media.Code: Select all
"job_csv_test2","job csv test 2. product","select",1,"short","short selection description","long","long selection description","media/image2.jpg","media/image2.jpg","EUR",1,"10.00","20.00",,,"job_csv_test","default","1.50","package-weight","home","default"
Your directory contains a hidden Mac file (.DS_Store.csv) that doesn't contain anything useful and gets skipped with the error message you see.lighthouse wrote: ↑23 Oct 2019, 18:14 Imported product lines from ".DS_Store.csv": 1/2 (Aimeos\Controller\Jobs\Product\Import\Csv\Standard)
Unable to import product with code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400": Code "]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowSidebar_{{400" must not be longer than 64 characters
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 2
- Joined: 23 Oct 2019, 16:01
Re: Import products with images from CSV
Thanks, everything is working now. No errors and I can see the images in the frontend but...
I still need the preview images in the CSV file. When I removed media.preview all images in /shop and /admin disappeared. I put back media.preview and everything is ok again. Do you have an explanation for this behavior or should I be worried? A fully functional image import is essential for my shop.
I still need the preview images in the CSV file. When I removed media.preview all images in /shop and /admin disappeared. I put back media.preview and everything is ok again. Do you have an explanation for this behavior or should I be worried? A fully functional image import is essential for my shop.
Re: Import products with images from CSV
You can add one (using "media.preview") or more (using "media.previews") preview images yourself to your products. If you don't and there's an image path available in "media.url" the preview images are generated automatically:
https://github.com/aimeos/ai-controller ... #L171-L177
Please keep care that the "media.url" path is relative to the ./public/ directory of your application (e.g. "media.url" => "media/image.jpg") and the files are there when you import them. Otherwise, the scale() method will fail:
https://github.com/aimeos/aimeos-core/b ... d.php#L170
https://github.com/aimeos/ai-controller ... #L171-L177
Please keep care that the "media.url" path is relative to the ./public/ directory of your application (e.g. "media.url" => "media/image.jpg") and the files are there when you import them. Otherwise, the scale() method will fail:
https://github.com/aimeos/aimeos-core/b ... d.php#L170
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Import products with images from CSV
I have a similar problem - I saved a product image below the public directory in '/images/prodimage.jpg',
so my csv contains for colum media.url only: images/prodimage.jpg
Unfortunately the image is not displayed in front- and backend.
Backend in product > media I see instead the image just "images/prodimage.jpg" - see sceenshot:
thanks!
so my csv contains for colum media.url only: images/prodimage.jpg
Unfortunately the image is not displayed in front- and backend.
Backend in product > media I see instead the image just "images/prodimage.jpg" - see sceenshot:
thanks!
- Attachments
-
- productimage.PNG (9.74 KiB) Viewed 5097 times
Re: Import products with images from CSV
Please ensure that your APP_URL in your .env file matches the domain and port in your browser.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Import products with images from CSV
I double checked APP_URL and seems to be correct. As AIMEOS is installed in /shop directory, I added /shop APP_URL:
APP_URL=http://x.x.x.x:80/shop
When opening http://x.x.x.x:80/shop/images/prodimage.jpg in a browser, the correct image is shown.
But frontend HTML only contains the APP_URL:
It looks like APP_URL and media.url are not being concatenated
APP_URL=http://x.x.x.x:80/shop
When opening http://x.x.x.x:80/shop/images/prodimage.jpg in a browser, the correct image is shown.
But frontend HTML only contains the APP_URL:
Code: Select all
<img class="" src="http://x.x.x.x:80/shop/" data-src="http://x.x.x.x:80/shop/" data-srcset="http://x.x.x.x:80/shop/ 1w" alt="images/prodimage.jpg" srcset="http://x.x.x.x:80/shop/ 1w">
Re: Import products with images from CSV
You must not include /shop in the APP_URL because it's a Laravel route, not a subdirectory and this will cause wrong URLs:
- Wrong: /shop/files/0/1/....jpg
- OK: /files/0/1/....jpg
Did you adapt the templates? The image links are generated with code like that:
https://github.com/aimeos/ai-client-htm ... #L168-L173
If you still use the same code, then the "preview" column is most likely empty or wrong. Did you upgrade and didn't run the setup tasks? You can also execute the media scale job to create new preview images based on your confiuguration (https://github.com/aimeos/aimeos-core/b ... hp#L31-L43):
- Wrong: /shop/files/0/1/....jpg
- OK: /files/0/1/....jpg
Did you adapt the templates? The image links are generated with code like that:
https://github.com/aimeos/ai-client-htm ... #L168-L173
If you still use the same code, then the "preview" column is most likely empty or wrong. Did you upgrade and didn't run the setup tasks? You can also execute the media scale job to create new preview images based on your confiuguration (https://github.com/aimeos/aimeos-core/b ... hp#L31-L43):
Code: Select all
./artisan aimeos:jobs media/scale
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Import products with images from CSV
when using APP_URL=http://x.x.x.x:80/shop
manually added images (backend > product > media) are displayed correctly:
but images via csv import are not displayed, image-path is missing:
when I change to APP_URL=http://x.x.x.x:80
/shop is missing and manually added images not displayed:
also images added using csv file are not displayed, image path is still missing:
So I think it is an issue with generated image pathes from the csv import
manually added images (backend > product > media) are displayed correctly:
Code: Select all
<div class="media-item">
<img class="" src="http://x.x.x.x:80/shop/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg" data-src="http://x.x.x.x:80/shop/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg" data-srcset="http://x.x.x.x:80/shop/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg 100w, http://x.x.x.x:80/shop/preview/a/e/ae8495d2873728c826481ffc528758dd.jpg 240w, http://x.x.x.x:80/shop/preview/2/a/2a6b775d33863bc6a1d2aff653e2852f.jpg 720w" alt="190948813 Gemüse _ Rüben.jpg" srcset="http://x.x.x.x:80/shop/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg 100w, http://x.x.x.x:80/shop/preview/a/e/ae8495d2873728c826481ffc528758dd.jpg 240w, http://x.x.x.x:80/shop/preview/2/a/2a6b775d33863bc6a1d2aff653e2852f.jpg 720w">
<meta itemprop="contentUrl" content="http://x.x.x.x:80/shop/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg">
</div>
Code: Select all
<div class="media-item">
<img class="" src="http://x.x.x.x:80/shop/" data-src="http://x.x.x.x:80/shop/" data-srcset="http://x.x.x.x:80/shop/ 1w" alt="images/prodimage_123.jpg" srcset="http://x.x.x.x:80/shop/ 1w">
<meta itemprop="contentUrl" content="http://x.x.x.x:80/shop/">
</div>
when I change to APP_URL=http://x.x.x.x:80
/shop is missing and manually added images not displayed:
Code: Select all
<div class="media-item">
<img class="" src="http://x.x.x.x:80/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg" data-src="http://x.x.x.x:80/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg" data-srcset="http://x.x.x.x:80/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg 100w, http://x.x.x.x:80/preview/a/e/ae8495d2873728c826481ffc528758dd.jpg 240w, http://x.x.x.x:80/preview/2/a/2a6b775d33863bc6a1d2aff653e2852f.jpg 720w" alt="190948813 Gemüse _ Rüben.jpg" srcset="http://x.x.x.x:80/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg 100w, http://x.x.x.x:80/preview/a/e/ae8495d2873728c826481ffc528758dd.jpg 240w, http://x.x.x.x:80/preview/2/a/2a6b775d33863bc6a1d2aff653e2852f.jpg 720w">
<meta itemprop="contentUrl" content="http://x.x.x.x:80/preview/2/3/23622508adbd0b6eb90f7eab2d0b8d70.jpg">
</div>
Code: Select all
<div class="media-item">
<img class="" src="http://x.x.x.x:80/" data-src="http://x.x.x.x:80/" data-srcset="http://x.x.x.x:80/ 1w" alt="images/prodimage_123.jpg" srcset="http://x.x.x.x:80/ 1w">
<meta itemprop="contentUrl" content="http://x.x.x.x:80/">
</div>
Re: Import products with images from CSV
Did you install Aimeos in a /shop subdirectory on your server?
Aimeos generates preview images for imported image paths in "aimeos/ai-controller-jobs" since "2019.10.8". Do you have a version before (you can check with "composer show")?
Another question: How does your CSV file and mapping looks like?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star