Nikita9999 Posted December 13, 2021 Posted December 13, 2021 (edited) Hi, I want to add a new column to backoffice list of product, so I've created a module to do that, here is the list of what I think I'll need to do and my questions : Override twig file : Done : modules/cs_displaysupplier/views/PrestaShop/Admin/Product/CatalogPage/Lists/list.html.twig -> add the new column for each product Done : modules/cs_displaysupplier/views/PrestaShop/Admin/Product/CatalogPage/Lists/products_table.html.twig -> add the title of my new column + filter : ok it's working ToDo : I need to bring the supplier reference to my twig file, I wanted to use a static method : ProductSupplier::getSupplierCollection but it's not possible directly inside the twig file, I've found this method : https://stackoverflow.com/questions/32920217/how-to-call-static-function-in-symfony2-twig-template#46636220 but I don't know wich controller do I need to override to do that ? Todo : I need to add the filter for the column -> is it possible to override the file /src/PrestaShopBundle/Entity/AdminFilter.php ? Perhaps there is an easiest way to do that ? thanks Edited January 11 by Nikita9999 (see edit history) Share this post Link to post Share on other sites More sharing options...
Nishith Nesdiya Posted December 13, 2021 Posted December 13, 2021 Hi Use actionAdminProductsListingFieldsModifier hook in your module. 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; } } Thank you 2 Share this post Link to post 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