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!
Re: Import products with images from CSV
I'm not sure if I got it right.
I process a csv file with new and updated products once a day (for csv example see comment from 18 Feb 2020, 12:43)
After the file is processed, images of the new or updated products are not displayed, images of already existing products are still displayed.
I now execute after each csv import:
Then all images are displayed correctly.
It seems that this generates new images (thumbnails etc.) for all products, and not only for new or updated products.
Is this the recommended / correct way?
If not, how can I updated / import products with images correctly?
I process a csv file with new and updated products once a day (for csv example see comment from 18 Feb 2020, 12:43)
After the file is processed, images of the new or updated products are not displayed, images of already existing products are still displayed.
I now execute after each csv import:
Code: Select all
artisan aimeos:jobs media/scale
It seems that this generates new images (thumbnails etc.) for all products, and not only for new or updated products.
Is this the recommended / correct way?
If not, how can I updated / import products with images correctly?
Re: Import products with images from CSV
Normally, preview images should be automatically generated on import:
https://github.com/aimeos/ai-controller ... #L172-L185
If this is not the case in your situation, please have a look at into the source code why that happens. Simply add a few debug statements at the code block to see which if/else branch is used. Then, we can see if it's a bug or if your CSV file contains something it shouldn't.
https://github.com/aimeos/ai-controller ... #L172-L185
If this is not the case in your situation, please have a look at into the source code why that happens. Simply add a few debug statements at the code block to see which if/else branch is used. Then, we can see if it's a bug or if your CSV file contains something it shouldn't.
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
following if/else branch is used
https://github.com/aimeos/ai-controller ... #L176-L177
I also attached an example of the csv file:
https://github.com/aimeos/ai-controller ... #L176-L177
I also attached an example of the csv file:
- Attachments
-
- productupdate.zip
- (585 Bytes) Downloaded 178 times
Re: Import products with images from CSV
What's your mapping configuration?
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
mapping:
Code: Select all
'mapping' => [
'item' => array(
1 => 'product.code', // e.g. unique EAN code
3 => 'product.label', // UTF-8 encoded text, also used as product name
2 => 'product.type', // type of the product, e.g. "default" or "selection"
9 => 'product.status', // enabled (1) or disabled (0)
),
'text' => array(
4 => 'text.type', // e.g. "short" for short description
5 => 'text.content', // UTF-8 encoded text
),
'media' => array(
39 => 'media.url', // relative URL of the product image on the server
//40 => 'media.type',
//42 => 'media.label',
//43 => 'product.lists.type',
),
'price' => array(
14 => 'product.lists.type',
7 => 'price.taxrate', // tax rate with decimals separated by a dot
16 => 'price.currencyid', // three letter ISO currency code
17 => 'price.value', // price with decimals separated by a dot
18 => 'price.quantity', // amount the quantity the price (for block pricing)
20 => 'product.lists.datestart',
21 => 'product.lists.dateend',
41 => 'price.taxrate',
23 => 'price.currencyid', // three letter ISO currency code
24 => 'price.value', // price_1
25 => 'price.quantity', // amount_1
26 => 'product.lists.datestart', // valid_from_1
27 => 'product.lists.dateend', // valid_to_1
28 => 'price.currencyid', // three letter ISO currency code
29 => 'price.value', // price_1
30 => 'price.quantity', // amount_1
31 => 'product.lists.datestart', // valid_from_1
32 => 'product.lists.dateend', // valid_to_1
33 => 'price.currencyid', // three letter ISO currency code
34 => 'price.value', // price_1
35 => 'price.quantity', // amount_1
36 => 'product.lists.datestart', // valid_from_1
37 => 'product.lists.dateend', // valid_to_1
),
'attribute' => array(
12 => 'product.lists.type', // e.g. "suggestion" for suggested product attributeproductlist = variant
10 => 'attribute.code', // code of an attribute, will be created if not exists
11 => 'attribute.type', // e.g. "size", "length", "width", "color", etc.
//44 => 'product.lists.type', // e.g. "suggestion" for suggested product attributeproductlist = variant
45 => 'attribute.code', // code of an attribute, will be created if not exists
46 => 'attribute.type', // e.g. "size", "length", "width", "color", etc.
),
'product' => array(
15 => 'product.code', // e.g. EAN code of another product
22 => 'product.lists.type', // e.g. "suggestion" for suggested product
),
'catalog' => array(
8 => 'catalog.code', // e.g. Unique category code
38 => 'catalog.code', // e.g. Unique category code
// 20 => 'catalog.lists.type', // e.g. "promotion" for top seller products
),
'stock' => array(
13 => 'stock.stocklevel',
),
]
Re: Import products with images from CSV
Strange, media preview isn't defined in your mapping. Can you check what's returned here:
https://github.com/aimeos/ai-controller ... d.php#L140
https://github.com/aimeos/ai-controller ... d.php#L140
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 added $context->getLogger()->log after L140
when using:
$context->getLogger()->log( 'preview 1: ' . $this->getValue( $list, 'media.preview', '' ));
empty, just prints: "preview 1: "
when using:
$context->getLogger()->log( 'preview 2: ' . $preview);
causes an error: "Unable to import product with code "123456": Array to string conversion"
when using:
$context->getLogger()->log( 'preview 3: ' . $separator);
empty, just prints: "preview 3: "
when using:
$context->getLogger()->log( 'preview 1: ' . $this->getValue( $list, 'media.preview', '' ));
empty, just prints: "preview 1: "
when using:
$context->getLogger()->log( 'preview 2: ' . $preview);
causes an error: "Unable to import product with code "123456": Array to string conversion"
when using:
$context->getLogger()->log( 'preview 3: ' . $separator);
empty, just prints: "preview 3: "
Re: Import products with images from CSV
OK, think we've found the problem:
explode( "\n", '' ) returns array( 0 => '' ) and therefore, the if/elseif/else thinks a preview path is available. We've added an additional check and now it should move on to the branch for creating the previews.
Can you please run
and test again?
explode( "\n", '' ) returns array( 0 => '' ) and therefore, the if/elseif/else thinks a preview path is available. We've added an additional check and now it should move on to the branch for creating the previews.
Can you please run
Code: Select all
composer req aimeos/ai-controller-jobs:2019.10.x-dev
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
unfortunately, its still not working.
now none of the three if/else branches from https://github.com/aimeos/ai-controller ... #L174-L180 are used
now none of the three if/else branches from https://github.com/aimeos/ai-controller ... #L174-L180 are used
Re: Import products with images from CSV
For existing products where you haven't change the URL, that's intentional because of:
https://github.com/aimeos/ai-controller ... d.php#L178
Try with new products or new URLs.
https://github.com/aimeos/ai-controller ... d.php#L178
Try with new products or new URLs.
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