Jump to content

Recommended Posts

Mis categorias han dejado de funcionar. No se muestran en la edicion de producto. Si salían listadas en Categorias pero no reconocía la categoria Raiz.

He borrado todas pero ahora no me deja crearlas me dice:

 


[PrestaShop \ PrestaShop \ Core \ Domain \ Category \ Exception \ CategoryConstraintException code 6]

 

Algun SQL para crearlas de 0? Para restaurarlas a como vienen por defecto.

 

saludos

Link to comment
Share on other sites

  • 3 weeks later...

A mi me pasa algo similar. Al entrar en el producto parece que se cargan pero al instante ya no se ven las categorías y no se pueden seleccionar, con lo que no se puede guardar el producto nuevo o modificar la categoría de alguno antiguo.

 

¿Alguna solución?

Link to comment
Share on other sites

(esto es para poner las categorias de inico)

Opcion 1

en la base de Datos por lo regular phpMyAdmin

 

TRUNCATE `ps_category`

 

y luego ingresas esto para generar las dos categorias principales

 

INSERT INTO `ps_category` (`id_category`, `id_parent`, `id_shop_default`, `level_depth`, `nleft`, `nright`, `active`, `date_add`, `date_upd`, `position`, `is_root_category`) VALUES
(1, 0, 1, 0, 1, 4, 1, '2019-02-02 00:00:01', '2019-02-02 00:00:01', 0, 0),
(2, 1, 1, 1, 2, 3, 1, '2019-02-02 00:00:01', '2019-02-02 00:00:01', 0, 1);

 

Opcion 2

trada de delarlo de esta forma que es lo principal como se muestra en la imagen

 

image.thumb.png.777c6071777750a62618f72e6b2e0aa8.png

Edited by Gerardo Martinez G (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Muchas gracias Burrots, exactamente era eso. Aunque acabo de ver tu mensaje y lo descubrí creando una instalación nueva y comparando las tablas, pero se agradece tu colaboración y también la de Gerardo de más arriba.

 

Un saludo

Carlos

 

En 9/9/2019 a las 3:41 AM, burrots dijo:

mira en l base de datos si en la tabla ps_category estan creadas la id 1 (root) y la 2 (home/inicio)

 

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...
8 hours ago, Paul C said:

This is all due to an upgrade in the past possibly not working properly or the issue being forgotten in later updates (it started around 2014 if I remember correctly)....

In stores that were installed before multi-shop was a thing the "Home" category was category 1. When multi-shop was introduced there was a need to have a "Home" category potentially for each shop (although multiple shops could have the same category tree and therefor the same "Home" I guess).

So.... after multi-shop was introduced category 1 now became "Root" and category 2 was "Home" with a parent_id of 1 (and confusingly the field is_root_category is set to 1 for the "Home" categories but not for the "Root" category).

If your install pre-dates multi-shop, then category 1  should have is_root_category = 1  and is "Home", plus it will have a parent_id which points to the "Root" category added when the catalog was upgraded for multi-shop (e.g. 132). That "Root" category (132 in this example) should have a parent_id of 0, is_root_category = 0 and active = 1. If you don't use multi-shop then you should only have ONE category with is_root_category = 1 (almost certainly this will be category 1). If you DO use multi-shop, then you may have more than one.

Due to the structure of the category tree you may have to rebuild the tree if you manually change entries in the database. So for my example you can do this whole thing using:

// Set 'home' category as the root category
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `is_root_category` = 1 WHERE `id_category` = 1';
$result = Db::getInstance()->Execute($query);

// Set the parent of the home category active and then set its parent to 0 (queries split for clarity)
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `active` = 1 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);
$query = 'UPDATE `'._DB_PREFIX_.'category` SET `id_parent` = 0 WHERE `id_category` = 132';
$result = Db::getInstance()->Execute($query);

// Rebuild the entire category tree
Category::regenerateEntireNtree();

 

 

On 9/9/2019 at 5:57 AM, Gerardo Martinez G said:

(esto es para poner las categorias de inico)

Opcion 1

en la base de Datos por lo regular phpMyAdmin

 

TRUNCATE `ps_category`

 

y luego ingresas esto para generar las dos categorias principales

 

INSERT INTO `ps_category` (`id_category`, `id_parent`, `id_shop_default`, `level_depth`, `nleft`, `nright`, `active`, `date_add`, `date_upd`, `position`, `is_root_category`) VALUES
(1, 0, 1, 0, 1, 4, 1, '2019-02-02 00:00:01', '2019-02-02 00:00:01', 0, 0),
(2, 1, 1, 1, 2, 3, 1, '2019-02-02 00:00:01', '2019-02-02 00:00:01', 0, 1);

 

Opcion 2

trada de delarlo de esta forma que es lo principal como se muestra en la imagen

 

image.thumb.png.777c6071777750a62618f72e6b2e0aa8.png

yo no me habia fijado pero tenia nrright 622 ( no se que significa esa columna)lo he cambiado aun no me funciona voy a eliminar categorias y a  ver si  me aparece bien

 

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...