Insert MPN into product URL for SEO purposes

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

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;

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

That will require a lot of extra work as it's the magic identifier both for url rewriting and picking the urls up.

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?

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

To remove the ID from product URLs, Permalinks is the only ready made solution.

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

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 ;)

Den här tråden har stängts på grund av lång inaktivitet. Det går inte att posta inlägg till den.
Se kod på GitHub