thirtybees / blocklayered

Academic Free License v3.0
0 stars 5 forks source link

Allowing filtering without ajax #8

Open pjrp opened 3 years ago

pjrp commented 3 years ago

Proposing a small addition to allow using direct urls to filter category pages. It:

Hooking to actionProductListOverride and catching 'selected_filters' get parameters would allow using direct urls like: https://front.thirtybees.com/coffee-and-tea?selected_filters=/categories-coffee/exclusive_buy-yes and even pagination https://front.thirtybees.com/coffee-and-tea?selected_filters=/categories-coffee/exclusive_buy-yes/&p=2

    public function hookActionProductListOverride($params)
    {
        if(Tools::getValue('selected_filters')){
            $selected_filters = $this->getSelectedFilters();
            $this->getProducts($selected_filters, $products, $nb_products, $p, $n, $pages_nb, $start, $stop, $range);
            $params['nbProducts'] = $nb_products;
            $params['catProducts'] = $products;
            $params['hookExecuted'] = true;
        }
    }

What do you guys think? Is there already a way to do this?

getdatakick commented 3 years ago

@pjrp I don't understand what the issue is, could you please explain a little bit more?

pjrp commented 3 years ago

@getdatakick sure

Cenário: Niara theme. Category listing, 20 products per page, some filter applied in layered navigation, currently in page 2.

The user scrolls to the bottom of the listing, clicks in a product and goes to the product page. Then, returns to the category listing.

What happens:

  1. Category listing loads page 1 unfiltered
  2. blocklayered.js kicks in, uses ajax and the url hashtag parameters to start loading the filtered product listing
  3. spinner gif shows up, listing is replaced with the correct filters, pagination and (depending on number of products) previous scroll position is lost

Go to https://front.thirtybees.com/gifts#/vegan-yes Scroll down and reload page. If you have a fast connection use browser tools to throttle.

Proposed change

Some thirtybees shops seem to have this sorted out. Check: https://4kidspoint.pl/promocje?manufacturer=625&manufacturer=625-923&orderby=name&p=2

Maybe this is theme or configuration related. What do you think?

edit: clarity