callback_object and callback in prestashop 1.7
Add Custom Content On Admin Core Controller RenderList In Prestashop
Prestashop admin controller first checks the callback parameter is set or not. If set then it checks the callback_object parameter.
Prestashop admin controller first checks the callback parameter is set or not. If set then it checks the callback_object parameter.
If we set the callback_object then the callback method will be searched inside the set object. Otherwise, it will search the callback method in the admin controller.
So how we are going to add our callback method?
So for adding our callback method, we are having a callback_object parameter in the params object.
In callback_object parameter, we will pass the object of the Module
class CallbackExample extends Module { ... public function hookActionAdminOrdersListingFieldsModifier($list) { $optionsOrderStatus = array(1 => 'Select'); if (isset($list['select'])) { $list['select'] .= ', o.`status` AS `type`'; } $list['fields']['type'] = array( 'title' => 'Type', 'align' => 'text-center', 'filter_key' => 'o!status', 'callback' => 'callbackMethod', 'orderby' => false, 'type' => 'select', 'list' => $optionsOrderStatus, 'callback_object' => Module::getInstanceByName($this->name) ); } public function callbackMethod($value) { if ($value) { return '<span class="label label-primary">Test Label</span>'; } } } https://webkul.com/blog/callback-method-to-add-custom-content-on-admin-core-controller-renderlist-in-prestashop/
Comments
Post a Comment