Allowing filtering without ajax #8

Open
opened 2021-02-05 10:30:21 -06:00 by pjrp · 2 comments
pjrp commented 2021-02-05 10:30:21 -06:00 (Migrated from github.com)

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

  • Prevents double loading products (currently products are reloaded via ajax call when the url has # filter or # pagination parameters).
  • Keeps compatibility with existing themes

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?

Proposing a small addition to allow using direct urls to filter category pages. It: - Prevents double loading products (currently products are reloaded via ajax call when the url has # filter or # pagination parameters). - Keeps compatibility with existing themes 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 2021-03-09 07:43:41 -06:00 (Migrated from github.com)

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

@pjrp I don't understand what the issue is, could you please explain a little bit more?
pjrp commented 2021-03-16 06:14:29 -05:00 (Migrated from github.com)

@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

  • Allow simple get request to load filtered and paged category pages

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

@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** - Allow simple get request to load filtered and paged category pages 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
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-thirtybees/blocklayered#8
No description provided.