-- Update --
I think the issue is in the category list view. It generates the product link to the product, for the page, in a loop.
I have it getting the product categories, and using that to build the URL.
I am thinking I will have to define which one i want to be the parent in an additional attribute, and then check that attribute for the category url-key that I want to use.
Any suggestions on the best way to accomplish this?
-- Update --
I have noticed that the issue seems to be because of the way magento creates it's url-key for a product is based off the highest Category ID of the categories it belongs to.
The largest category ID defines the url-key.
So if I have product1 in category1, category2, and category3; I want the url key of category1 (i.e. site.com/category1/product1), but if category3 has a larger ID than category1, the url key will be site.com/category3/product1, even when you navigate to site.com/category1 the link is to site.com/category3/product1.
I could remove it from additional categories that have a higher ID, but that is not an ideal solution.
Is there anyway to set the full url key? or is there somewhere i can force the preference of a certain category's url-key?
-- Original --
I am attempting to import products and categories via CSV.
I have this process working, and everything imports without throwing an error.
I have my products belonging to anywhere from 1 to 3 categories.
In the import, the url key for most of the products is correct, it just seems to be some random ones that do not get the url key of the first parent (category).
It seemed that initially they all were using the last, so i switched the order to be reversed.
This fixed most all of them, but ones that are set up pretty much the same, and should have the same parent url key, are randomly using one of the other categories as a URL key.
I tried deleting everything (Products and Categories), cleared my cache storage. Checked that the URL Rewrites were removed, and tried importing again.
I get the same result.
The does not seem to be any ties to visibility, as one which is incorrect is set to 4, and another is 1 (which i would expect 1 to be erroring if either of the two.)
I have most of the categories inactive, I want to roll out additional categories after launch.
I would think it would take preference to the visible categories, but the one i want to to show up in is visible, and it gets placed in an inactive one.
I am not sure what else may cause this. Or where else to look for the problem. I do not see anything that would indicate why those specific products are different. But each time I import, the same ones fall into the wrong category.
Any help would be greatly appreciated. If someone could at least point me in the right direction.
I can give more specific examples if required, I didn't want to confuse things more than this already is.