Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for filter with commerce product #1010

Open
wants to merge 3 commits into
base: 7.x-2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Plugin/resource/DataProvider/DataProviderEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ protected function getReferencedId($value, ResourceFieldInterface $resource_fiel
$field_info = field_info_field($resource_field->getProperty());
// We support:
// - Entity Reference.
// - Commerce Product
// - Taxonomy Term.
// - File & Image field.
// - uid property.
Expand All @@ -1146,6 +1147,10 @@ protected function getReferencedId($value, ResourceFieldInterface $resource_fiel
$target_entity_type = $field_info['settings']['target_type'];
$bundles = empty($field_info['settings']['handler_settings']['target_bundles']) ? array() : $field_info['settings']['handler_settings']['target_bundles'];
}
elseif (!empty($field_info['type']) && $field_info['type'] == 'commerce_product_reference') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this duplicated code? If so, we should have an || condition in the if clause instead of duplicating.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right!! 👍

$target_entity_type = $field_info['settings']['target_type'];
$bundles = empty($field_info['settings']['handler_settings']['target_bundles']) ? array() : $field_info['settings']['handler_settings']['target_bundles'];
}
elseif (!empty($field_info['type']) && $field_info['type'] == 'file') {
$target_entity_type = 'file';
}
Expand Down
1 change: 1 addition & 0 deletions src/Plugin/resource/Field/ResourceFieldEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ public static function fieldClassName(array $field_definition) {

switch ($field_info['type']) {
case 'entityreference':
case 'commerce_product_reference':
case 'taxonomy_term_reference':
return '\Drupal\restful\Plugin\resource\Field\ResourceFieldEntityReference';

Expand Down