Jump to content

Parent category lost when saving a category


Recommended Posts

Hello,

 

I have upgraded to Prestashop 1.5.6 and I'm having a weird behavior of the categories.

 

I have a tree of categories, with a specified parent category for each child.Something very simple, nothing special.

 

home

       Sport

       Music

           Rock

           Pop

       Computers

 

 

Now, When I edit one of them and I save it, the category lose the parent category and go up to the root level. For instance, I edit "pop", save it and the result of the tree is:

 

home

       Sport

       Music

           Rock

       Computers

Pop

 

Now, when I edit the category on the root (in this case "pop") I cannot assign a parent category.

 

Had someone this behavior?

Do you know the reason?

What should I do to fix it?

 

Many thanks in advance,

post-551244-0-47663900-1392744658_thumb.jpg

Edited by joa_pen (see edit history)
Link to comment
Share on other sites

 

 

Now, When I edit one of them and I save it, the category lose the parent category and go up to the root level. For instance, I edit "pop", save it and the result of the tree is:

while edit option to mark category as root is unchecked?

  • Like 1
Link to comment
Share on other sites

Hello Vekia,

 

I think you have pointed to the issue, I have reviewed the category form, and the field "root category" is not shown. It should be between the field "Parent Category" and the field description, but it is not there,

 

Why this field is not being show?

How can enable it?

 

Many thanks in advance

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

i have the same problem while editing my categories, they " jump" after saving, one level higher and become home categories. the problem is, home categories can´t be assigned to a parent category!

 

@ joa_pen : Do you solve that Problem?

 

Regards

Link to comment
Share on other sites

I updated to version Prestashop 1.5.6.

 

I performed some actions:

 

1.- I was able to identify the entries that had the issue. I did review the database level and nothing weird there.

 

2.- I createed new categories with the same names and replace the wrong categories by new ones. This worked, in conjunction with point #3

 

3.- I uninstalled the category module, and then installed it again.

 

Now it works.

Link to comment
Share on other sites

Sadly this does not solve the issue for me. Any other suggestions apart from downgrading?

When i edit a category it still places it in root and parent becomes uneditable through the admin panel.

Due to the amount of categories we have its not prefered to edit everything in PHPmyAdmin.
 

Link to comment
Share on other sites

The ability to define a category as a root category disappeared in version 1.5.5.0 onwards.

My guess is that you have upgraded to a more recent version from a pre-1.5.5.0 version where you had defined some categories as root categories. Then, when you try & amend a category in the more recent version, PS can't recognise your previous category structure, so makes it into an 'orphan' category.

As I said, this is a guess!

 

Now, When I edit one of them and I save it, the category lose the parent category and go up to the root level. For instance, I edit "pop", save it and the result of the tree is:

 

home

       Sport

       Music

           Rock

       Computers

Pop

joa_pen, to test my theory, can I ask whether you had Sport, Music & Computers defined as root categories before your upgrade?

Thanks, Dave

Link to comment
Share on other sites

The ability to define a category as a root category disappeared in version 1.5.5.0 onwards.

My guess is that you have upgraded to a more recent version from a pre-1.5.5.0 version where you had defined some categories as root categories. Then, when you try & amend a category in the more recent version, PS can't recognise your previous category structure, so makes it into an 'orphan' category.

As I said, this is a guess!

 

joa_pen, to test my theory, can I ask whether you had Sport, Music & Computers defined as root categories before your upgrade?

Thanks, Dave

 

Dave,

 

Do you think that if i would change the root settings manually in database it would fix the problem? 

 

 

Link to comment
Share on other sites

Dave,

 

Do you think that if i would change the root settings manually in database it would fix the problem? 

 

 

It would be worth a try, but make sure to take a backup of your database before you do it, and test it thoroughly afterwards.

I believe the category structure is defined via a combination of the category id, the parent category, whether it's a root category and the vales of nleft and nright.

My concern is that if you change categories from being root to non-root (leaving only Home as a root category) and update parent categories if needed, the values in nleft and nright may still mean that your category structure doesn't have integrity.

NB confusingly, there is a hidden category called root (with id_category = 1) which is NOT set as a root category. Do not adjust that or the Home category.

The safest option, although pretty tedious in the short term, is to spend some time reinputting the categories and deleting the existing ones as joa_pen did. It may save you time in the long run.

Cheers, Dave

Link to comment
Share on other sites

I solve it by changing the id-parent value on the ps_category. I assigned all the parrent category to the root "id_parent=1" after that  i deleted the empty"new appeared" home category on the same table.

I hope that continues to work for you, but it might have been safer to replicate the default PS structure. This has the (hidden) category 'root' with id_category = 1 which is the parent of 'Home' which has id_category = 2 and then have the other categories as children of Home.

Cheers, Dave

Link to comment
Share on other sites

@stottycabanas,

 

I did not try your theory in the way you mentioned, but I review the mySQL table to ensure that the field defines an entry as "root category".

 

@k.kannegieter

If you change the root settings manually in database, it will fix the problem temporally. The issue will come when you edit again the entry or some of the childs.

 

Did you try to remove the "Block_categories" module, and then install again?

Link to comment
Share on other sites

  • 1 month later...

After some months, the root cause of this issue seems to be still there.

 

We have changed a couple of category titles from the store and the issue came back: the category missed the link to the parent category and now is under the root category.

 

:(

Link to comment
Share on other sites

×
×
  • Create New...