A
A
AgeWalker2020-12-11 15:31:16
Prestashop
AgeWalker, 2020-12-11 15:31:16

How to remove # from filter url (PrestaShop blocklayered module)?

CMS PrestaShop
Module: blocklayered

Good afternoon, I have a question that I can not solve either by myself or with the help of Google.
Saw a lot of similar questions, but not a single implementation.

Situation:
The site has a filter. When filtered, it returns the following url:
/catalog#/type-kurtka_ukor_bryuki/gost-124280_2014
The url contains a # (pound sign). My job is to get her out of there. What would the url be one of the following options:
/catalog/type-kurtka_ukor_bryuki/gost-124280_2014

/catalog/filter/type-kurtka_ukor_bryuki/gost-124280_2014


Tried to do the following:
File /modules/blocklayered/blocklayered.php
Changed
$type_filter['values'][$key]['link'] = $categorie_link.'#'.ltrim($parameters, '/');

on the
$type_filter['values'][$key]['link'] = $categorie_link.'/filter'.ltrim($parameters, '/');

changed
'current_friendly_url' => '#'.$filter_block['current_friendly_url']/*((int)$n == (int)$nb_products) ? '#/show-all': '#'.$filter_block['current_friendly_url']*/,

on the
'current_friendly_url' => '/filter'.$filter_block['current_friendly_url']/*((int)$n == (int)$nb_products) ? '#/show-all': '#'.$filter_block['current_friendly_url']*/,


File /themes/custom/js/modules/blocklayered/blocklayered.js
Changed
if (current_friendly_url != '#'){
      window.location.href = current_friendly_url;
}

on the
if (current_friendly_url != '/filter'){
      window.location.href = current_friendly_url;
}

changed
if (current_friendly_url != '#/show-all')
$('div.clearfix.selector1').show();

on the
if (current_friendly_url != '/filter/show-all')
$('div.clearfix.selector1').show();


File modules/blocklayered/blocklayered.js
Changed
if (window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
  {
    var params = window.location.href.split('#')[1];
    reloadContent('&selected_filters='+params);
  }

on the
if (window.location.href.split('/filter').length == 2 && window.location.href.split('/filter')[1] != '')
  {
    var params = window.location.href.split('/filter')[1];
    reloadContent('&selected_filters='+params);
  }


What I have achieved with this.
In theory, I expected to see a url like this:
/catalog/filter/type-kyrtka
But I got a redirect to
/filter/type-kyrtka
and a 404 error.

How to solve this situation ... I do not know.
In theory, you need to somehow rewrite the url control somewhere. Whatever he throws where I don't need ...

I checked manually url
/catalog/filter/type-kyrtka
Gives a 404 error.

----
Why is this needed?
Needed for SEO.
Variant with #! will not work, because Google ignores this. Already checked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ITLandgraf, 2020-12-12
@ITLandgraf

Look at the redirect in .htaccess - Prestashop outputs in the URL line something completely different from what it actually generates. Find where the output of the URL string for the filter is and convert the new version to a working internal address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question