CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

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!
TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 11 Oct 2023, 07:40

Hello!

I would like to run the CSV import multiple times.

I set the update to change the following attributes.

Code: Select all

'controller' => [
	'product' => [
                   'import' => [
                       'csv' => [
                           'processor' => [

			       // modify by update import
                               'attribute' => [
                                   'listtypes' => [
                                       'myattribute1',
                                       'myattribute2'
                                   ],
                               ],
				...
Then I get the following error:

Code: Select all

Unable to import product with code "2": SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '125124-attribute-default-65287-1.' for key 'mshop_product_list.unq_msproli_pid_dm_ty_rid_sid':
INSERT INTO "mshop_product_list" (
"parentid", "key", "type", "domain", "refid", "start", "end",
"config", "pos", "status", "mtime", "editor", "siteid", "ctime"
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
I tried to find the cause of the error, but so far I have not succeeded.
I rewrote:
from:

Code: Select all

INSERT INTO "mshop_product_list"
to:

Code: Select all

INSERT IGNORE INTO "mshop_product_list"
But this is not a permanent solution.
Thanks if you have any ideas.

TGergo

PHP 8.1
"aimeos/aimeos-laravel": "^2022.10",
Windows + Homestead Vagrant Linux

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

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by aimeos » 12 Oct 2023, 08:56

Does that also occur if you remove your "listtypes" configuration?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 12 Oct 2023, 12:50

No, if I take it out, it runs flawlessly.

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 17 Oct 2023, 07:14

Other problem with this feature.

When I add an attribute to the array
for example: 'myattribute1'

the first value is: text1
I change the value in the csv file: text2

will add text2 but not delete text1

so I have two values:
myattribute1 : text1
myattribute1 : text2

but my csv file contains only one

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

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by aimeos » 19 Oct 2023, 10:01

Your configuration is wrong and must be:

Code: Select all

	'controller' => [
		'jobs' => [
			'product' => [
				'import' => [
					'csv' => [
						'attribute' => [
							'listtypes' => ['myattribute1', 'myattribute2'],
						],
					],
				],
			],
		],
	],
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 24 Oct 2023, 07:54

Thanks! That was the problem.

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 26 Oct 2023, 11:33

TGergo wrote: 24 Oct 2023, 07:54 Thanks! That was the problem.
Another problem
It worked on my local machine but not on the test server.
same error, did not delete the old attributes
the solution: change Redis queue worker numprocs=2 to numprocs=1

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by TGergo » 27 Oct 2023, 07:22

aimeos wrote: 19 Oct 2023, 10:01 Your configuration is wrong and must be:

Code: Select all

	'controller' => [
		'jobs' => [
			'product' => [
				'import' => [
					'csv' => [
						'attribute' => [
							'listtypes' => ['myattribute1', 'myattribute2'],
						],
					],
				],
			],
		],
	],
No, I think the documentation is also bad, this is the right one:

controller/common/product/import/csv/processor/attribute/listtypes

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

Re: CSV Import attribute INSERT INTO "mshop_product_list" Duplicate entry

Post by aimeos » 28 Oct 2023, 09:30

At the moment, both are working:
https://github.com/aimeos/ai-controller ... hp#L72-L73

In 2024+, the "controller/common/..." setting will be removed.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply