Closed choleaoum closed 4 years ago
Hello,
I am sorry you had this trouble with this problem. I hope I can explain this a bit.
Basically, the importer is a product importer. It is not intended to import categories. The only thing the importer does is to create a basic entry in the category tables, for the categories that did not yet exist, so that the products can be linked to it. So it's just a quick initial population of categories.
The reason why the categories are created at the admin-level is that the category's name serves as an identifier in the import. It is important that it remains unchanged. This is not a problem because the name of the category can be set at the store view level, and changing it later at this level will not interfere with the importer.
Once the categories are created, the importer uses the admin name to look up the id. Categories are not updated.
As to the url_rewrite table. I am looking at the code and I see that an entry is written to the url_rewrite table at store view 0 (admin). This was just silly of me. It doesn't do anything. url_rewrite entries are not inherited, an entry needs to exist for each store view.
You are correct to change the store_id to 1 to make it work for your (only) store view. This works well for the initial population of the categories.
I hope this helps you to understand why things work as they do. Let me know your thoughts.
greetings,
Patrick
Ah this was a great explanation, it's been awhile since I worked with Magento so it's all a beccome a bit foreign to me. So I guess it's safe to hard code the store_id's myself. I don't have any intentions on having multiple stores just yet, but I was under the presumption that although there are no other categories with store_id > 0, everything would just default to that category?
Thanks. Yes changing the store id's to 1 is fine. The value of normal attributes defaults to the admin level. Not so for the url_rewrite table.
I will change the importer in a few days so that it generates url_rewrites for the existing store views, in stead of the store view 0 (which has no use).
I made the fix and released 1.4.1.
So it seems I'm having an issue getting my category rewrites to work. I am running a brand new installation of Magento 2.3.4 and the first thing I did was install this extension. I am populating products just fine, they are showing up using the url_key.
The categories work using the "https://www.example.com/catalog/category/view/s/denim-jeans/id/16/". Although, when I attempt to access the category via the url_key/request_path such as "https://www.example.com/denim-jeans" it does not work.
In the url_rewrites table, categories are being generated for store_id 0 and products are being generated for store_id 1.
My solution, if I change my url category rewrites from store_id 0 to 1 from the url_rewrites table, the categories work. But it does not seem like the appropriate solution to constantly update the store_id to 1.
I've spent days researching prior to posting and just needed some clarification. My understanding is that if the only categories are store_id = 0, then it is the default category for all stores. I am only running the default store that came with my installation.