rt000v95 Posted February 11, 2016 Share Posted February 11, 2016 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 More sharing options...
JFCS Posted February 12, 2016 Share Posted February 12, 2016 No sé si te ayudará en algo pero el error lo que te está diciendo es que el producto ya está en la categoría al que intentas asociarlo. Link to comment Share on other sites More sharing options...
rt000v95 Posted February 13, 2016 Author Share Posted February 13, 2016 Gracias por responder. Al final decidí comprar un modulo para evitar problemas. Un saludo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now