shop:onExtendReportFilters
The shop:onExtendReportFilters event allows to filter the order report and graph data by your own parameters in the Reports area. Please see the documentation on list filters.
Below is an example module to filter by shop customers treated as "dealers."
Structure:
- modules
-- dealerfilter
--- classes
---- dealerfilter_module.php
--- models
---- dealerfilter_filter.php
dealerfilter_module.php
<?
class DealerFilter_Module extends Core_ModuleBase {
protected function createModuleInfo() {
return new Core_ModuleInfo(
"Test: Data Filter",
"",
"Limewheel Creative Inc."
);
}
public function subscribeEvents() {
Backend::$events->addEvent('shop:onExtendReportFilters', $this, 'extend_filters');
}
function extend_filters($controller) {
if(!($controller instanceof Shop_Orders_Report))
return;
$controller->filter_filters['dealer'] = array('name'=>'Dealer', 'class_name'=>'DealerFilter_Filter', 'prompt'=>'Please choose dealers statuses you want to include to the report. Orders with other dealers will be excluded.', 'added_list_title'=>'Added Dealers');
}
}
dealerfilter_filter.php
<?
class DealerFilter_Filter extends Db_DataFilter {
public $model_class_name = 'Users_User';
public $list_columns = array('name');
public function prepareListData() {
$className = $this->model_class_name;
$obj = new $className();
return $obj;
}
public function applyToModel($model, $keys, $context = null) {
$model->where('customer_calculated_join.created_user_id is not null and customer_calculated_join.created_user_id in (?)', array($keys));
}
public function asString($keys, $context = null) {
return 'and shop_customers.created_user_id is not null and shop_customers.created_user_id in '.$this->keysToStr($keys);
}
}
Previous: Reporting events
Return to Reporting events

