Hello
my urls to product pages has weird hash after url that has informations about attrbutes, for example:
domain.com/t-shirt/1-1-red-shirt.html#/3-color-red/36-size-m/42-stan-bardzo_dobry_5_6
how i can remove the part #/3-color-red/36-size-m/42-stan-bardzo_dobry_5_6 ?
Expert answer
This part of url contains information about combination, so when you will access to product page prestashop will automatically select attributes defined in the url.
If you want to remove it, you will need to modify the prestashop's core or use a module pretty urls (it removes hash with attributes, id product and also id product attrbute from url).
Modification of core
if you want to just remove the hash with attributes info you need to modify the Link.php class that is available in directory classes/Link.php
there is a function that builds urls to product pages:
there is a function that builds urls to product pages:
public function getProductLink( $product, $alias = null, $category = null, $ean13 = null, $idLang = null, $idShop = null, $ipa = 0, $force_routes = false, $relativeProtocol = false, $addAnchor = false, $extraParams = array()
){ ...}
inside this function you can find code like (somewhere near line 221)
$anchor = $ipa ? $product->getAnchor((int) $ipa, (bool) $addAnchor) : '';
modify it to:
$anchor = '';
It works great. If I wanted to remove a category or subcategory and product ID from product url, how do I edit it?
ReplyDeleteFrom: https://example/long-sleeve/5268-13168-top-with-long-sleeves.html
To: https://example/top-with-long-sleeves.html
hello
Deletego to preferences > traffic (prestashop 1.7)
go to preferences > seo & urls (prestashop 1.6)
there is a section to manage "schema of urls"
change the schema for "product pages" from: {category:/}{rewrite}.html to:{rewrite}.html
Hi
ReplyDeleteYou simply replace the line 220 of the file classes / link.php:
$ anchor = $ ipa? $ product-> getAnchor ((int) $ ipa, (bool) $ addAnchor): '';
by
$ anchor = '';
clear cache
example url:
https://www.trophee-sportif.com/trophees-ceramique/3223-209228-trophee-ceramique.html#/654-option_gravure-non
bECOMES
https://www.trophee-sportif.com/trophees-ceramique/3223-trophee-ceramique.html
is that all it takes? and it works?
thank you
I am affraid that with this method the attribute swich on product page will not work correctly, but of course case requires verification
Delete
ReplyDeleteYou simply replace the line 220 of the file classes / link.php:
$ anchor = $ ipa? $ product-> getAnchor ((int) $ ipa, (bool) $ addAnchor): '';
by
$ anchor = '';
clear cache
example url:
https://www.trophee-sportif.com/trophees-ceramique/3223-209228-trophee-ceramique.html#/654-option_gravure-non
bECOMES
https://www.trophee-sportif.com/trophees-ceramique/3223-trophee-ceramique.html
is that all it takes? and it works?
thank you
Thank you
ReplyDeleteit does not work error 500
I tried in the override / classes directory to insert this link.php file.
It works but in the back office it creates a conflict of pdf generation for invoices, delivery notes etc.
On the customer side, no problem.
But that's not good too.
do you have a module that works for version 1.7.2.4 ?
ReplyDeletepretty clean urls is ready to work with all currently available prestashop 1.7.x releases including 1.7.2.4
Delete