s22_tech Moderator Från United States Medlem sedan okt. 2019 s22_tech 10 dec. 2019 21:27 How difficult would it be to change the URL that LiteCart produces? I want the manufacturers item number in the URL instead of the auto-incremented id, so I need to replace the id with code. I’ve looked at /includes/library/lib_route.inc.php but I’m not seeing how the URL is constructed.
tim Founder Från Sweden Medlem sedan maj 2013 tim 10 dec. 2019 22:38 See includes/routes/url_product.inc.php Find $new_path .= functions::general_path_friendly($product->name, $language_code) .'-p-'. $product->id; Replace with $new_path .= functions::general_path_friendly($product->name .'-'. $product->mpn, $language_code) .'-p-'. $product->id;
s22_tech Moderator Från United States Medlem sedan okt. 2019 s22_tech 10 dec. 2019 23:14 Thanks! That'll work. I was hoping to actually replace the product id to keep the URL as short as possible, but that breaks the cart.
tim Founder Från Sweden Medlem sedan maj 2013 tim 10 dec. 2019 23:15 That will require a lot of extra work as it's the magic identifier both for url rewriting and picking the urls up.
s22_tech Moderator Från United States Medlem sedan okt. 2019 s22_tech 11 dec. 2019 00:11 So what about the category number? Can that be removed safely? From your response above and from reading the Alternative SEO URLs mod, I take it that the answer is yes. So I removed it from url_product.inc.php and it works. However, could there be any problems down the road doing this?
tim Founder Från Sweden Medlem sedan maj 2013 tim 11 dec. 2019 00:56 When you remove the category id from the product url LiteCart will show the tree path and breadcrumbs using default category id. I think you might be asking for permalinks in the long run: [url=https://www.litecart.net/en/addons/162/permalinks]https://www.litecart.net/en/addons/162/permalinks[/url]
s22_tech Moderator Från United States Medlem sedan okt. 2019 s22_tech 11 dec. 2019 01:11 Not really. Those are nice, short URL's but not what I'm looking for. Basically, I want to keep the URL the same as it is now, but just remove the category number (-c-123), and replace the product id with the code (-c-123). Removing the id would require a lot of work, so I'm OK with it for now. I've gotten it to where I almost want it, so my only question at this point is if it's OK in the long run to remove the category id on product URL's? As I mentioned, it's working fine right now without it. I just want to make sure there'll be no surprises down the road.
tim Founder Från Sweden Medlem sedan maj 2013 tim 11 dec. 2019 01:34 To remove the ID from product URLs, Permalinks is the only ready made solution.
s22_tech Moderator Från United States Medlem sedan okt. 2019 s22_tech 31 dec. 2019 00:03 I was never able to get the URL to be exactly how I wanted it, and to have it work properly, so I ended up purchasing the Permalinks add-on. I wish I had done it sooner. It's an easy and clean way of having simplified, SEO-friendly url's. It works perfectly, and is tightly integrated with LiteCart. If I had accomplished what I wanted, to make a change to one of my url's would have changed all of them. With Permalinks, I can change as few or as many as I need, leaving the others untouched. Very nice! I highly recommend it.
tim Founder Från Sweden Medlem sedan maj 2013 tim 31 dec. 2019 14:29 Happy it solved your problem :) And I'm sure you learned something new on your way. Not all dead ends is a waste of time ;)