Problem/Motivation

Is it possible to get an entity type field like commerce_product commerce_variation node and taxonomy_term ?

I see there is a

Product type (type)

field but that only gives me the bundle not the entity_type.

Issue fork search_api-3228382

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lexsoft created an issue. See original summary.

mikran’s picture

Component: Documentation » Plugins
Category: Support request » Feature request

mikran’s picture

Status: Active » Needs review
mikran’s picture

We had similar need so I went ahead and implemented it. @lexsoft could you test if this does what you had in mind?

lexsoft’s picture

Sure, will check it later next week. Thanks for the good work!

lexsoft’s picture

Hi @mikran,

The processor works but it shows the machine name for blocks as well. It will be great if we can limit what entity types we want to index.

drunken monkey’s picture

Good idea, thanks a lot both to lexsoft for the suggestion and to mikran for the implementation. Great that you even included a test already!

Unfortunately, due to #3190024: Problem with test dependencies when testing issue forks, we cannot use issue forks in this project but need to use patches instead. (Although I see that you managed to get a passing test by switching back to Drupal 8.9 – interesting …)

However, aside from that this seems more or less good to go. While I’m not sure how many people will actually have a use case for this, it is a very small change, so should be harmless enough to add.
It might actually be good to have a) the map of possible values and their labels available somewhere and b) a generic property for the bundle, too – but both of these should probably just be added later, in case people actually ask for them.

I just had a few minor changes – please see the attached patch and interdiff. If these look good to you, then only this remains to clear up before committing:

The processor works but it shows the machine name for blocks as well. It will be great if we can limit what entity types we want to index.

I’m not sure what you mean by that? You are indexing blocks but don’t want the field to contain block for those? That seems to be quite a specific requirement, not sure we want to support that out-of-the-box.

drunken monkey’s picture

Any more feedback on this? I could commit once this is cleared up.

mikran’s picture

Status: Needs review » Reviewed & tested by the community

I just had a few minor changes – please see the attached patch and interdiff.

interdiff looks good to me and I like the idea of adding a generic bundle property too. This was not a big issue as all the entities I've used are providing the bundle property already and aggregated field works fine for those, even if it was slightly more work to configure.

  • drunken monkey committed 716deec on 8.x-1.x authored by mikran
    Issue #3228382 by mikran, drunken monkey: Added an "Entity type" field.
    
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks for the feedback.
Committed. Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.