Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product has a non-null url_path attribute #25

Closed
senders opened this issue May 19, 2021 · 10 comments
Closed

Product has a non-null url_path attribute #25

senders opened this issue May 19, 2021 · 10 comments

Comments

@senders
Copy link

senders commented May 19, 2021

What does the message "Product has a non-null url_path attribute, this is known to cause problems with url rewrites in Magento. It's advised to remove this value from the database." mean? How to fix it?

I can't find any problems.

Also new created products are listed when running catalog:product:integrity:urlpath.

I have this on different Magento installations.

@hostep
Copy link
Member

hostep commented May 19, 2021

Hi @senders

The problem with the url_path attribute for products is that it influences the url rewrites, but you can't manipulate the value of that attribute using the backend of Magento.
Which means that if you want to change the url_key and thus the url rewrite of a product using the backend of Magento, it won't be possible because the "hidden" url_path attribute has precedence over the url_key attribute.

The url_path attribute for products is a remainder from the old Magento 1 days where it behaved a bit differently. Somehow it was included in Magento 2, even though the behavior changed and it actually never gets filled up with data if you create a product using the backend of Magento. Thus it's a bit a meaningless field, even though it's still being used in generating url rewrites, which is very weird and can probably be considered as a bug in Magento 2.

So the recommendation is to always have the url_path attribute of products as empty.

We've seen that url_path attribute getting filled up many times in the past for shops that were migrated from Magento 1 to Magento 2 using the magento data migration tool, it was a bug for a long time in that tool, but was fixed in version 2.3.5 of that tool by magento/data-migration-tool@b5ad54f

In your case, if you see this problem pop up even after new products are created, then it probably means that these products aren't being created in the backend of Magento, but by some sort of script that explicitly sets the url_path attribute of products. I would advise you to find how this happens and disable this and only use the url_key attribute in the future and make sure the values of the url_path attribute of products gets removed.
Please make sure to test these changes very well before executing this on production of course 🙂

I hope this helps!

@hostep
Copy link
Member

hostep commented Jul 15, 2021

Closing, because of no feedback and not really a problem.

@hostep hostep closed this as completed Jul 15, 2021
@eBusinessAtlantique
Copy link

Got that problem and indexing didn't run correctly. Some products disappeared in categories. Randomly.
Solution :
Search your url_path attribute in eav_attribute table.
Find all the lines with it in your catalog_product_entity_varchar table.
Delete all entries with this attribute.

Hope this helps...

@hgati
Copy link

hgati commented Sep 26, 2023

All products have been automatically uploaded using the script below.
I have only stored the url_key attribute as below, and I'm not sure what the url_path attribute is as it seems unfamiliar to me.

@hostep
Copy link
Member

hostep commented Sep 26, 2023

You can just delete the values for the product attribute url_path in your database, that should solve the things the report mentions. It's probably some left over from a Magento 1 to Magento 2 migration.

Just be aware that your url rewrites might generate differently after doing so, it will now use the url_key instead of the url_path to generate url rewrites for products (which should be a good thing, since that's what you want).

@hgati
Copy link

hgati commented Sep 26, 2023

That's strange. There are two instances of the url_path and url_key attributes in the database.
I have never migrated from Magento 1 to 2, and I have never set up Magento 1. I started with Magento 2.

@hostep
Copy link
Member

hostep commented Sep 26, 2023

It's not strange, because both products & categories have a url_path and url_key attribute.
Also, you shouldn't delete the attribute itself, but the attribute values for the url_path attribute of the product entities, which are stored in the catalog_product_entity_varchar db table.

See here for an SQL query to delete them (I wouldn't hardcode the entity_type_id to '4' though, in most cases it will be 4, but maybe in specific cases it might be something else)

If you didn't start from M1, then I have no idea where those url_path entries for products came from, that is indeed strange 🙂

@hgati
Copy link

hgati commented Sep 26, 2023

Ahh, so the entity_type_code distinguishes whether it's a category or a product, right?
That's why there are two of them for each.
In the catalog_product_entity_varchar table, are you saying should delete the url_path?
In Magento 1, It used url_path, but in Magento 2, It should only use url_key, is that correct?

@hgati
Copy link

hgati commented Sep 26, 2023

I originally started configuring Magento 2 in single-store mode. However, I later switched to multi-store mode and encountered some issues related to store codes. I vaguely remember that there was an issue where product changes were not reflecting, and after struggling for a few days, I found out that some data from the single-store mode was still present, causing the problem with data not being displayed. It's possible that the url_path might be related to the data from the single-store mode. 😁

@hgati
Copy link

hgati commented Sep 26, 2023

https://github.com/elgentos/magento2-regenerate-catalog-urls#whats-the-difference-between-url_key-and-url_path

I think the article you recommended will be really helpful. I wasn't quite sure about the concept of url_path, but as I read through this post, I'm starting to grasp it better. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants