Jump to content

Editing a product - Cannot find breadcrumb because category does not exist


Ray UK

Recommended Posts

Hi,

So I have a strange problem here.

On a shop running PS8.1 one of the products is not editable using the "New Product Page".
Stock can be added using the stock page, and the product is visible on the front and working fine and there are other products in assigned to the same category, which can be edited.

Yet when an edit is attempted on this product it throws this error

PrestaShop\PrestaShop\Core\Domain\Category\Exception\ CategoryNotFoundException
in src/Adapter/Category/Repository/CategoryRepository.php (line 213)

            ;
            $category = $categoryQb->execute()->fetchAssociative();
            if (empty($category)) {
                throw new CategoryNotFoundException($categoryId, 'Cannot find breadcrumb because category does not exist');
            }
            $categoryName = $category['name'];
            $qb = $this->connection->createQueryBuilder();

I know It's still an "experimental" page, but it works on every other product except this one.

Any ideas as to what it is referring to.

Thanks

Link to comment
Share on other sites

Maybe this helps:

How to Diagnose and Fix:

  • Check the product’s default category in your database.

SELECT id_product, id_category_default FROM ps_product WHERE id_product = [YOUR_PRODUCT_ID];
Replace [YOUR_PRODUCT_ID] with the real product ID.

  • See if that category exists.

SELECT * FROM ps_category WHERE id_category = [id_category_default_from_above];
If this returns no rows, that’s your issue: the product is pointing to a deleted category.

  • Check which categories the product is actually assigned to.

SELECT * FROM ps_category_product WHERE id_product = [YOUR_PRODUCT_ID];
Pick a valid category ID from this list to use as the new default.

  • Fix the product’s default category reference.

UPDATE ps_product SET id_category_default = [A_VALID_CATEGORY_ID] WHERE id_product = [YOUR_PRODUCT_ID];

  • If you’re using multistore, also update:

UPDATE ps_product_shop SET id_category_default = [A_VALID_CATEGORY_ID] WHERE id_product = [YOUR_PRODUCT_ID];

Link to comment
Share on other sites

Thanks for the reply patron.

I tried the statement you suggested and they all point to the same category Id of 159.

159 is the correct cat id and that category is working fine on the front end.image.thumb.jpg.c79db26260efa90763a58a5934a604c4.jpg


im replying on phone as my computer has been blocked from accessing the forum lol 

  • Haha 1
Link to comment
Share on other sites

28 minutes ago, Ray UK said:

Thanks for the reply patron.

I tried the statement you suggested and they all point to the same category Id of 159.

159 is the correct cat id and that category is working fine on the front end.image.thumb.jpg.c79db26260efa90763a58a5934a604c4.jpg


im replying on phone as my computer has been blocked from accessing the forum lol 

Understood, now also mobile.  I'll look at later and see if I can help more, its useful to display results of each sql for further analysis.

  • Like 1
Link to comment
Share on other sites

Posted (edited)

can i reply on computer yet...

UPDATE: computer access is back.  Support told me how to clear my cache, restart my computer and disable browser add-ons.  im glad they are there as I would never have known how to do that..  I didnt try those as I know that wasnt the problem. Its seems cloudfare has now unblocked me

Edited by Ray UK (see edit history)
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...