Geronimo2012 Posted January 21 Share Posted January 21 Hi, I'm trying to add a column to the Product administration page. I created a module for that, see code below. The hooks to modify the grid definition and query are not called ever. I cleared the cache, refreshed everything, checked that ps_hook_module contains the desired hooks, which it does. However I still cannot manage to get the extra column to show up. <?php use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DataColumn; use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; class JsGridProduct extends Module { /** @var array */ public const MODULE_HOOKS = [ 'actionProductGridDefinitionModifier', 'actionProductGridQueryBuilderModifier', ]; /** @var string */ public const DATE_ADD_FIELD_NAME = 'date_add'; public function __construct() { $this->name = 'jsgridproduct'; $this->author = 'Jeroen van der Schoot'; $this->version = '1.0.0'; $this->ps_versions_compliancy = ['min' => '1.7.7.0', 'max' => _PS_VERSION_]; parent::__construct(); $this->displayName = $this->l('Add column on the product list'); $this->description = $this->l('Displays the added date of the product on your products list in back office'); } /** * Installer. * * @return bool */ public function install() { return parent::install() && $this->registerHook(static::MODULE_HOOKS); } public function hookActionProductGridDefinitionModifier(array $params) { /** @var \PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface $definition */ $definition = $params['definition']; $definition ->getColumns() ->addAfter( 'active', (new DataColumn(static::DATE_ADD_FIELD_NAME)) ->setName($this->l('Date added')) ->setOptions([ 'field' => static::DATE_ADD_FIELD_NAME, ]) ) ; $filters = $definition->getFilters(); $filters->add((new Filter(static::DATE_ADD_FIELD_NAME, DateTimeType::class)) ->setTypeOptions([ 'required' => false, ]) ->setAssociatedColumn(static::DATE_ADD_FIELD_NAME) ); } public function hookActionProductGridQueryBuilderModifier(array $params) { /** @var \Doctrine\DBAL\Query\QueryBuilder $queryBuilder */ $queryBuilder = $params['search_query_builder']; $queryBuilder->addSelect('p.`date_add`'); } } 1 Link to comment Share on other sites More sharing options...
Daresh Posted January 21 Share Posted January 21 As far as I know, product list is not a Grid so it won't work. Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 21 Author Share Posted January 21 2 hours ago, Daresh said: As far as I know, product list is not a Grid so it won't work. Here I found something similar for Orders, is the implementation for Orders different than for Products? Link to comment Share on other sites More sharing options...
Daresh Posted January 21 Share Posted January 21 Yes it is. Link to comment Share on other sites More sharing options...
endriu107 Posted January 21 Share Posted January 21 In product list grid was added in prestashop 8.1. Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 22 Author Share Posted January 22 Is there a way to customize the administration product list? Link to comment Share on other sites More sharing options...
Daresh Posted January 22 Share Posted January 22 What version of PrestaShop do you have? Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 22 Author Share Posted January 22 6 minutes ago, Daresh said: What version of PrestaShop do you have? 8.1.2 Link to comment Share on other sites More sharing options...
endriu107 Posted January 22 Share Posted January 22 14 minutes ago, Geronimo2012 said: 8.1.2 Yes, easiest way is use module. My module in products list now allow to enable/disable column like: EAN13, UPC, MPN, ISBN and weight, but can be extend on other column. You can create your own module and manage needed columns or buy any module that have option you need. Link to comment Share on other sites More sharing options...
Daresh Posted January 22 Share Posted January 22 In 8.1.2 your code should work, I just tested it out by extending my Gridder module with date_add and date_upd columns, your code looks quite good. Are you sure the hooks got attached? The Symfony debugger may be helpful here. Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 22 Author Share Posted January 22 2 hours ago, Daresh said: In 8.1.2 your code should work, I just tested it out by extending my Gridder module with date_add and date_upd columns, your code looks quite good. Are you sure the hooks got attached? The Symfony debugger may be helpful here. When I open Product page in bottom I notice: Should I expect hooks hookActionProductGridDefinitionModifier and hookActionProductGridQueryBuilderModifier here? Link to comment Share on other sites More sharing options...
Daresh Posted January 22 Share Posted January 22 Yes, like this: Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 22 Author Share Posted January 22 3 minutes ago, Geronimo2012 said: When I open Product page in bottom I notice: Should I expect hooks hookActionProductGridDefinitionModifier and hookActionProductGridQueryBuilderModifier here? Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 22 Author Share Posted January 22 I tried to Debug this with xdebug but I don't hit breakpoints in DoctrineGridDataFactory.getData() Link to comment Share on other sites More sharing options...
Geronimo2012 Posted January 23 Author Share Posted January 23 Anyone any clue why hooks are not called? Or pointers how to debug this? Link to comment Share on other sites More sharing options...
Smart-Web Posted yesterday at 06:44 AM Share Posted yesterday at 06:44 AM On 1/23/2024 at 4:05 AM, endriu107 said: Yes, easiest way is use module. My module in products list now allow to enable/disable column like: EAN13, UPC, MPN, ISBN and weight, but can be extend on other column. You can create your own module and manage needed columns or buy any module that have option you need. Do you have a demo of your module online? Looks very promising, but I would like to see this work first. Link to comment Share on other sites More sharing options...
endriu107 Posted yesterday at 07:32 AM Share Posted yesterday at 07:32 AM No there is no demo available currently, all I can show now i video from very first version od this module Link to comment Share on other sites More sharing options...
Smart-Web Posted 3 hours ago Share Posted 3 hours ago 23 hours ago, endriu107 said: No there is no demo available currently, all I can show now i video from very first version od this module Hi, this looks good and your English is good too. However your entire website is in Polish only? I don't speak Polish and google translate is not doing a great job. If you want to sell your modules, please provide an english version of your site. Thanks 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