Jump to content

overriding CategoryController to show products not from one specific id


Recommended Posts

Hello.

I'm using prestashop 1.7.2.4 to write my module.

I'd like to create a controller that extends CategoryController so it will show products based on a specific query 

based on the get parameters that controller received.

the thing is that I have no clue how to even start.

I created .a module with FrontController with ModuleRoutes and everything works properly.

no idea how to extend the CategoryController. I'm not even 100% sure that's the way to go

any information regarding this issue would be greatly appreciated.

 

 

Link to comment
Share on other sites

Think that is not way you should go. Do check how native controllers work like NewProductsController and

also connected NewProductsProductSearchProvider

All product list controllers extend ProductListingFrontController.php class and do check its code and how

all works there. For module you should also check hook productSearchProvider.

It is interesting subject so please share how module progressing.

  • Like 1
Link to comment
Share on other sites

21 hours ago, razaro said:

Think that is not way you should go. Do check how native controllers work like NewProductsController and

also connected NewProductsProductSearchProvider

All product list controllers extend ProductListingFrontController.php class and do check its code and how

all works there. For module you should also check hook productSearchProvider.

It is interesting subject so please share how module progressing.

 

ok so I'm trying to extend ProductListingFrontController .

in the init function I point the doProductSearch function to 'catalog/listing/product-list.tpl'

I'm a bit confused about overriding the getProductSearchQuery() function.

I need somehow to create a ProductSearchQuery object that will have custom query that will support filtering by the new tables I created.

i'm a bit confused about that. can anyone provide any information how to move forward? thanks

 

 

Link to comment
Share on other sites

  • 1 month later...

so the solution was pretty easy.

I duplicate the controller that is in charge of showing new products and modified it to suite my needs.

so I duplicate controller NewProductsController and I also duplicated the adapter NewProductsProductSearchProvider and modified it to join with my own tables.

 

Link to comment
Share on other sites

  • 1 year later...
On 12/17/2017 at 1:48 AM, Kfir Ozer said:

so the solution was pretty easy.

I duplicate the controller that is in charge of showing new products and modified it to suite my needs.

so I duplicate controller NewProductsController and I also duplicated the adapter NewProductsProductSearchProvider and modified it to join with my own tables.

 

hi, maybe its too late,

i am also trying to do this but i dont know where to put my query(or create the query object). looking inside ProductListingFrontController i find getProductSearchVariables() function but it gets the query from getProductSearchQuery() function and looking further getProductSearchQuery() defination theres nothing just one line which is "abstract protected function getProductSearchQuery()" which return nothing. which function/method did you call inside your frontcontroller ?

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...