Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The following breaks the Manage Fields page of a taxonomy term (admin/structure/taxonomy/product_category/fields):
function commerce_services_entity_info_alter(&$info) {
$info['taxonomy_term']['bundle keys']['bundle'] = 'vocabulary_machine_name';
}
The field_ui.admin.inc requires the bundle key to be "machine_name".
Comment | File | Size | Author |
---|---|---|---|
#4 | 2024813-4-bundle-key.patch | 3.47 KB | wodenx |
Comments
Comment #1
bgilhome CreditAttribution: bgilhome commentedHere's a patch:
Comment #2
ivanbueno CreditAttribution: ivanbueno commented"machine_name" is already the default bundle keys name, so deleting the hook_entity_info_alter fixes the problem. No patch needed. However, the issue rszama is trying to solve with the entity_info_alter will come back, and needs to be addressed differently.
Comment #3
wodenx CreditAttribution: wodenx commentedI think this arises from a misconception as to the purpose of the 'bundle keys' property. This is used by field_extract_bundle() to obtain the bundle name from a bundle object - not from an entity. For example, taxonomy_terms (for which, I suspect, this confusing pattern was invented) have bundles which are themselves objects (vocabularies). The property of a taxonomy_vocabulary object that contains the bundle which that vocabulary defines is
$vocabulary->machine_name
. The property of a taxonomy_term entity that contains the bundle to which that entity belongs is$term->vocabulary_machine_name
. Hence, the entity info for taxonomy specifiesThe
['entity keys']['bundle']
and['bundle keys']['bundle']
are intentionally different.To get the bundle of a taxonomy term (or any entity), we should call
entity_extract_ids()
and notfield_extract_bundle()
.In any event, the
hook_entity_info_alter()
implementation should definitely be removed. In addition, we should probably replace most occurrences offield_extract_bundle()
withentity_extract_ids()
-- or better yet, obtain the bundle via an entity metadata wrapper.Comment #4
wodenx CreditAttribution: wodenx commentedHere's a patch. Haven't tested it, but it should serve as a starting point.
Comment #5
srjoshThis is a patch that just removed the hook_entity_info_alter() function.
Comment #6
danielmrichards CreditAttribution: danielmrichards commentedTested the patch in #5 and the issue was resolved for me.
Comment #7
zterry95 CreditAttribution: zterry95 commentedthe hook_entity_info_alter needed to be removed.
As is break the taxonomy manage field overview page.
Also it waste time of developer to dig such kind of mistake...
Comment #8
mstrelan CreditAttribution: mstrelan commentedI would think #4 is more appropriate to use than #5.
Comment #9
ganesan g CreditAttribution: ganesan g commentedDeleting the commerce_services_entity_info_alter fixes the issue. Thanks for the patch.
Comment #10
lachezar.valchev CreditAttribution: lachezar.valchev at FFW commentedHi,
The description at #3 is spot on and the patch from #4 is the correct way to fix the issue.
If you just remove the
commerce_services_entity_info_alter()
without replacing thefield_extract_bundle()
withentity_extract_ids()
you may definitely face issues with the taxonomy terms, especially when thecommerce_services_flatten_fields()
function is called on taxonomy terms.I think we should have this patch committed.
Regards,
Lachezar
Comment #11
Andrej Galuf CreditAttribution: Andrej Galuf commentedAgree on #4 being the correct approach.
Comment #12
olofbokedal CreditAttribution: olofbokedal at Odd Hill commented#4 fixed the issue for me.
Comment #13
torgosPizza#4 solved this issue for me as well.
Also of note, the issue referenced in the removed entity_info_alter hook, #1736466: taxonomy_entity_info() uses the wrong 'bundle_keys' bundle name for taxonomy_term included a patch from Ryan, but that turned out to not be the issue as explained in later comments.
To me this is RTBC and should get into Commerce Services ASAP!
Comment #14
lyalyuk CreditAttribution: lyalyuk at AnyforSoft commented#4 Work for me. Thanks!
Comment #15
brijesh09 CreditAttribution: brijesh09 as a volunteer and commentedAll the Patch worked for me
@ https://www.drupal.org/files/commerce_services.entity_info_alter.taxonom...
@https://www.drupal.org/files/2024813-4-bundle-key.patch
Thanks
Comment #16
arunkumark+1 Patch is working as expected. Also, able to add and remove fields.
Comment #17
mglamanConfirming #4 is the proper fix.