![]() 'IF(LENGTH(pa.`phone_mobile`) = 0 OR pa.`phone_mobile` IS NULL, test which phone is filled, or concatenate both ![]() Here is the complete function to do it: public function hookActionCustomerGridQueryBuilderModifier(array $params) Let’s display both if filled, or one or other. Prestashop uses 2 fields for phone: « phone » & « phone_mobile ». So we will need to join this table, and get the phone. Phones are stored in ps_address database, it means, a customer can have many addresses, and we just want to display the last one for example. So ok, we have a new column, now we need to fill it. We add the new column to the search Filter too, this way, we will be able to search and order our new column. Here, we just set a new column, and we place it after the « email » column. add a new column after the email column Then, we will define our hook functions, first, let’s add the new column « Phone », we want here to display the phones of our customer: public function hookActionCustomerGridDefinitionModifier(array $params) & $this->registerHook('actionCustomerGridQueryBuilderModifier') ![]() & $this->registerHook('actionCustomerGridDefinitionModifier') So, let’s add the code we need to these hooks in your module, first we need to install our module and register the hooks: public function install() Now, if we check the documentation, we can find some hooks which allow to work on any listing in the backoffice:ĪctionCustomerGridDefinitionModifier: allow to define columns, reorder… as you may see, just change « Customer » by the listing you want to changeĪctionCustomerGridQueryBuilderModifier: allow to redefine the query for the listing, same, replace « Customer » by the listing you want to edit $this->description = $this->trans('Modifie les colonnes du backoffice Prestashop') īasic structure for a module, we just define the name and some params. $this->displayName = $this->trans('Colonnes custom dans les listings') Why a module ? just because we don’t want to touch the core code, and overrides are not easy to maintain. honestly, the Prestashop’s documentation about it is pretty clear: If you start to have a lot of customers in your application, and you want to display quickly their phone numbers for example, because you need to be able to search by it, or any other field, then you can create your own module and redefine the listing.įirst, let’s create a new module.
0 Comments
Leave a Reply. |