Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Faceted search doc #1371

Merged
merged 3 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions development/components/faceted-search/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Faceted search
menuTitle: Faceted search
---

# Faceted search

{{% children %}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: Inside the module
weight: 30
---

# Inside the module

This page should be useful for someone willing to contribute to the module. To do so he/she needs to understand the module logic and structure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @Hlavtox can you have a look please?


## Exposed endpoints

The module

- is accessible from the front-office on dedicated pages, using hooks
matks marked this conversation as resolved.
Show resolved Hide resolved
- has a back-office configuration page
- provides 3 endpoints to be regularly visited (by a cron for example) in order to reindex the products
matks marked this conversation as resolved.
Show resolved Hide resolved

The 3 exposed endpoints are in the root folder of the module.

Indexation results are stored in specific SQL tables. This allows to query flat tables ready for querying, instead of having complex SQL queries being fired at runtime when user is searching on front-office.

## Filter system

On front-office, user can see multiple blocks. Blocks are linked to a filter and the population. The population is the products matching the filter.

Blocks are what is the most expensive to generate. Each link is a query.

Filters have a complex structure allowing deep queries such as OR and AND, under, equals, above... and at the end of the processing SQL queries are built from them to be run against the database.

QUESTION: where are the Filters objects? they are arrays ?
matks marked this conversation as resolved.
Show resolved Hide resolved

### Post processing

After finding the population matching a filter, a post processing can be applied to alter the data in order to control how it is presented to user.

For example you might have a collection of prices ranging from 21.88 to 72.82 but this is not nice to display. So you can apply post processing to force the display to be a range from 0 to 100, although the data available goes from 21.88 to 72.82 .

### Caching

Filter results are cached inside SQL in order to improve performance. Same query being sent twice can then reuse the result from first fetch.


## Highlights of the `src` folder

### Specific hook structure

There were so many hooks used in the module that the hook actions have been moved outside of the main file, unlike many other modules. A hook dispatcher is in charge of linking the main module file and calling the right hooks. Hook actions will be found in `src/Hook`

### MysQL adapter

Inside `src/Adapter` is the code responsible for mapping faceted search queries to MySQL queries

### Copy-paste of the Core

Some of the code inside the module used to be inside the Core repository. It was extracted as it was useful only for the module and this avoids having different behaviors depending on which shop the module was installed.

## SQL naming

SQL tables are based on naming convention `layered` because this was the previous name of the module.

## How it's plugged on the Core

In the Core front controller ProductListingFrontController a hook is used to check whether a module can provide a SearchProvider. Faceted search module uses this hook to provide its SearchProvider and allow using it.
16 changes: 16 additions & 0 deletions development/components/faceted-search/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Introduction
weight: 20
---

# Introduction

PrestaShop front-office provides a faceted search capability, powered by the module https://github.com/PrestaShop/ps_facetedsearch/

The module allows customers to search for products using multiple filters and mix them.

It is built on the top of a filtering engine that maps user input to SQL queries.

INSERT SCREENSHOT

INSERT A BIT MORE STUFF