forked from drupalcommerce/commerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commerce.views.inc
30 lines (27 loc) · 1.13 KB
/
commerce.views.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* @file
* Views integration for Commerce.
*/
use Drupal\Core\Entity\ContentEntityType;
/**
* Implements hook_views_data_alter().
*/
function commerce_views_data_alter(array &$data) {
// Override the bundle views handlers for commerce content entities.
$entity_types = \Drupal::service('entity_type.manager')->getDefinitions();
foreach ($entity_types as $entity_type) {
if ($entity_type instanceof ContentEntityType && strpos($entity_type->id(), 'commerce_') === 0) {
// Translatable entities have a data table. Non-translatable ones
// (such as Order) have only a base table.
if ($data_table = $entity_type->getDataTable()) {
$data[$data_table][$entity_type->getKey('bundle')]['field']['id'] = 'commerce_entity_bundle';
$data[$data_table][$entity_type->getKey('bundle')]['filter']['id'] = 'commerce_entity_bundle';
}
else {
$data[$entity_type->getBaseTable()][$entity_type->getKey('bundle')]['field']['id'] = 'commerce_entity_bundle';
$data[$entity_type->getBaseTable()][$entity_type->getKey('bundle')]['filter']['id'] = 'commerce_entity_bundle';
}
}
}
}