Skip to content

Allowing filtering without ajax #8

@pjrp

Description

@pjrp

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions