Im trying to make a abandoned cart notification module, trying to relate my notification table with the commerde_order table by its order_id in views. Right now i have this in my hook_views_data
function commerce_abandoned_cart_notification_views_data(){
$data = array();
$data['commerce_abandoned_cart_notification']['table']['group'] = t('Commerce abandoned cart notification');
$data['commerce_abandoned_cart_notification']['table']['join'] = array(
'commerce_order' => array(
'left_field' => 'order_id',
'field' => 'order_id',
),
);
$data['commerce_abandoned_cart_notification']['table']['base'] = array(
'field' => 'id',
'title' => t('Commerce abandoned cart notification'),
'help' => t('Commerce abandoned cart notification'),
);
$data['commerce_abandoned_cart_notification']['id'] = array(
'title' => t('Notification ID', array(), array('context' => 'A Commerce abandoned cart notification internal ID')),
'help' => t('The unique internal identifier of the notification.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['commerce_abandoned_cart_notification']['order_id'] = array(
'title' => t('Order ID', array(), array('context' => 'A Commerce order ID')),
'help' => t('The unique internal identifier of the order.'),
'relationship' => array(
'base' => 'commerce_order',
'field' => 'order_id',
'handler' => 'views_handler_relationship',
'label' => t('Referencing order'),
),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
return $data;
}
The problem is that when creating a view i do not see my relationship to commerce orders or viceversa, (the hook works because i can create a view of type commerce_abandoned_cart_notification and add some of its fields). I know there is a commerce_abandoned_cart_notification or commerce_notification module but they seem incomplete and/or abadoned
Should i use hook_views_data_alter to alter commerce_order relatations and add one to my custom table?