daniele dexter Posted June 20, 2022 Share Posted June 20, 2022 (edited) Hello everybody, in the product list I would like to add a new column (supplier). I saw the query that is used at the moment and on db I did the test by adding what I needed. Now my doubt is how to go about adding the LEFT JOIN to make sure it is correctly added to the current selection. I found a guide that said to take action in the file override / controllers / admin / AdminProductsController.php Here inside the __construct () function I added the following code: parent :: __ construct (); $ this -> _ join. = 'LEFT JOIN `pr_manufacturer` m ON p.`id_manufacturer` = m.id_manufacturer'; $ this-> fields_list ['manufacturer'] = array ( 'title' => $ this-> l ('Manufacturer'), 'filter_key' => 'm! name' ); I also deleted the cache / class_index.php file I don't see the new column added yet. Can anyone help me figure out where to act or if I was wrong to write the code? Thanks in advance Edited November 11, 2022 by daniele dexter (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted June 20, 2022 Share Posted June 20, 2022 Kindly use the folowing hook for the same : actionAdminProductsListingFieldsModifier , below code is get supplier data in your product list page public function hookActionAdminProductsListingFieldsModifier($params) { $params['sql_select']['supplier'] = [ 'table' => 'sup', 'field' => 'name', 'filtering' => \PrestaShop\PrestaShop\Adapter\Admin\AbstractAdminQueryBuilder::FILTERING_LIKE_BOTH ]; $params['sql_table']['sup'] = [ 'table' => 'supplier', 'join' => 'LEFT JOIN', 'on' => 'p.`id_supplier` = sup.`id_supplier`', ]; $supplier_filter = Tools::getValue('filter_column_name_supplier', false); if ($supplier_filter && $supplier_filter != '') { $params['sql_where'][] .= " p.id_supplier = " . $supplier_filter; } } Link to comment Share on other sites More sharing options...
daniele dexter Posted June 21, 2022 Author Share Posted June 21, 2022 15 hours ago, Knowband Plugins said: Kindly use the folowing hook for the same : actionAdminProductsListingFieldsModifier , below code is get supplier data in your product list page public function hookActionAdminProductsListingFieldsModifier($params) { $params['sql_select']['supplier'] = [ 'table' => 'sup', 'field' => 'name', 'filtering' => \PrestaShop\PrestaShop\Adapter\Admin\AbstractAdminQueryBuilder::FILTERING_LIKE_BOTH ]; $params['sql_table']['sup'] = [ 'table' => 'supplier', 'join' => 'LEFT JOIN', 'on' => 'p.`id_supplier` = sup.`id_supplier`', ]; $supplier_filter = Tools::getValue('filter_column_name_supplier', false); if ($supplier_filter && $supplier_filter != '') { $params['sql_where'][] .= " p.id_supplier = " . $supplier_filter; } } Hello @Knowband Plugins, i can't find the indicated hook on the Design / Positions section. So I looked if the string was present in some file and I found it in two files: public_html / src / PrestaShopBundle / Controller / Admin / ProductController.php public_html / src / Adapter / Product / AdminProductDataProvider.php In the first file I find this comment: / ** * 2 hooks are triggered here: * - actionAdminProductsListingFieldsModifier * - actionAdminProductsListingResultsModifier. * / In the second I find it with: Hook :: exec ('actionAdminProductsListingFieldsModifier', [ Now I'd like to ask you where should I add the function you indicated to me. I changed it by putting the exact name of my table and that's it. Thanks for your help Daniele Link to comment Share on other sites More sharing options...
Prestachamps Posted June 21, 2022 Share Posted June 21, 2022 Hello, Before making any changes, I recommend reading this documentation. In this example, the grid is extended at the client list.https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/modify-grid-in-module/https://github.com/PrestaShop/example-modules/tree/master/demoextendsymfonyform1 Have a nice day. Kind regards, Leo Link to comment Share on other sites More sharing options...
daniele dexter Posted June 24, 2022 Author Share Posted June 24, 2022 Not being very experienced I preferred to opt for the purchase of a module. I was comfortable with this and recommend it: https://addons.prestashop.com/en/administration/85331-product-catalog-custom-display.html Link to comment Share on other sites More sharing options...
Knowband Plugins Posted June 27, 2022 Share Posted June 27, 2022 On 6/21/2022 at 2:03 PM, daniele dexter said: Hello @Knowband Plugins, i can't find the indicated hook on the Design / Positions section. So I looked if the string was present in some file and I found it in two files: public_html / src / PrestaShopBundle / Controller / Admin / ProductController.php public_html / src / Adapter / Product / AdminProductDataProvider.php In the first file I find this comment: / ** * 2 hooks are triggered here: * - actionAdminProductsListingFieldsModifier * - actionAdminProductsListingResultsModifier. * / In the second I find it with: Hook :: exec ('actionAdminProductsListingFieldsModifier', [ Now I'd like to ask you where should I add the function you indicated to me. I changed it by putting the exact name of my table and that's it. Thanks for your help Daniele @Daniele, You need to register that hook in your module before using that. Kindly check the screenshot that the hook is present in the admin product listing page : https://nimb.ws/6u5VwX 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