Jump to content

Imposible Asociar Productos A Categoria Padre


rt000v95

Recommended Posts

Hola, he utilizado esta consulta:

SET @position = 0;INSERT INTO `ps_category_product` SELECT c.`id_parent`, cp.`id_product`, @position:=@position+1 as `position` FROM `ps_category_product` cp LEFT JOIN `ps_category` c ON (cp.`id_category` = c.`id_category`) WHERE `id_parent` > 1 AND cp.`id_product` NOT IN (SELECT `id_product` FROM `ps_category_product` WHERE `id_category` = c.`id_parent`)

para intentar asociar los productos a su categoria padre, pero, cuándo la ejecuto me lanza el siguiente error:

consulta SQL: 
INSERT INTO `ps_category_product`
SELECT c.`id_parent` , cp.`id_product` , @position := @position +1 AS `position`
FROM `ps_category_product` cp
LEFT JOIN `ps_category` c ON ( cp.`id_category` = c.`id_category` )
WHERE `id_parent` >1
AND cp.`id_product` NOT
IN (
SELECT `id_product`
FROM `ps_category_product`
WHERE `id_category` = c.`id_parent`)MySQL ha dicho: 
#1062 - Duplicate entry '2-442' for key 'PRIMARY' 

La ejecuto en ps_products...

 

Alguna idea de porque ?

He mirado en el foro pero no he encontrada nada que me ayude...

 

Muchas gracias.

Un saludo

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...