Kfir Ozer Posted October 28, 2017 Share Posted October 28, 2017 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 More sharing options...
Daresh Posted October 28, 2017 Share Posted October 28, 2017 I think you can't override CategoryController, cause it's among the new architecture. Link to comment Share on other sites More sharing options...
Kfir Ozer Posted October 28, 2017 Author Share Posted October 28, 2017 1 hour ago, Daresh said: I think you can't override CategoryController, cause it's among the new architecture. so how can I implement a controller that shows products based on a specific sql queries (on new tables i created) ? Link to comment Share on other sites More sharing options...
razaro Posted October 28, 2017 Share Posted October 28, 2017 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. 1 Link to comment Share on other sites More sharing options...
Kfir Ozer Posted October 29, 2017 Author Share Posted October 29, 2017 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 More sharing options...
Kfir Ozer Posted December 16, 2017 Author Share Posted December 16, 2017 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 More sharing options...
Pierre_d Posted December 18, 2017 Share Posted December 18, 2017 I've overridden CategoryController, ProductController and SearchController for the same purpose, plus a custom ProductSearchProvider. You can read the four first technical articles here: https://okai.be/articles-techniques/. If you've specific questions, I can share the code with you. Link to comment Share on other sites More sharing options...
mmkaw Posted December 10, 2019 Share Posted December 10, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now