Jump to content

How to create custom sql query on category listing page in Prestashop 1.7


pankaj_kumar

Recommended Posts

In Prestashop 1.7 i want to modify the default SQL query of the listing products on the category page. I cant found which SQL query returning products on category page.

there is custom fields added to product table priority(1,2,3) and state (0,1)

so need to display products above matching columns using custom SQL query.

Inside Class Category.php getProducts() function is not executing on category page if facted search module is enabled.  If i am disabling the facted search module then getProducts() function is executing. 

I need to modify default product listing sql query on Category page, But i cant find the way to modify it. 

Link to comment
Share on other sites

As i can remember (not tested) the products are loaded in this function:
https://github.com/PrestaShop/PrestaShop/blob/1.7.8.3/classes/controller/ProductListingFrontController.php#L251

This loads a product search provider you can check which provider is loaded and try to extend this. Keep in mind that this could return any search provider which is calculated at:
https://github.com/PrestaShop/PrestaShop/blob/1.7.8.3/classes/controller/ProductListingFrontController.php#L265

Edited by jacob_v_dam (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...