Hi,
I am facing some major issues while using solr indexed field in views.
Issue :
PHP Fatal error: Call to a member function getType() on a non-object in /var/www/html/core/modules/views/src/Plugin/views/field/Field.php on line 348getType()
Also I am getting notice for using fields like price from ubercart.
Notice: Undefined index: price in Drupal\views\Plugin\views\field\Field->getFieldStorageDefinition() (line 333 of /var/www/html/core/modules/views/src/Plugin/views/field/Field.php).
Kindly help.
Regards,
Jaswinder
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | Screenshot_20190617_165542.png | 22.22 KB | niklan |
| #10 | 2674750-10--views_display_computed_fields.patch | 1.06 KB | drunken monkey |
Comments
Comment #2
chera.jaswinder commentedComment #3
lendudeThis sounds like an issue with Search API Views, which isn't part of the Views module. Moving it to the Search API queue.
Comment #4
lendudeComment #5
drunken monkeyWhich module versions are you using? The latest Alphas from both Search API and Search API Solr, and a recent Drupal Core release? Otherwise, please update and see if that helps.
PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.
Comment #6
danbruder commentedI am getting the same thing - here is more information:
Versions:
- Drupal 8.1.7
- Search API 8.x-1.0-alpha16
Steps to reproduce:
1. Configure Search API Database as search backend
2. Create node index that has the path alias as a field
3. Create a view of indexed data
4. Add the indexed path alias field
Error output:
Comment #7
drunken monkeyFor the path alias, this is a known problem which should have been fixed with #2284199: Problem with taxonomy term parent. Since the path alias field uses a "custom storage", it's (apparently) not possible to access it in a generic way (like we want/have to). The latest Search API versions therefore don't allow indexing the path alias (or, e.g., taxonomy term parents) anymore until the Drupal Core problem is fixed.
Comment #8
legolasboI am closing this issue because information was requested over a year ago, but no new information has been provided since. Please reopen this issue with the requested information if you think that this issue is still relevant.
Comment #9
niklanReopen issue, having the same problem and having the steps for reproducing.
1. Add custom computed field to the node type. For example.
2. Create ComputedPriceFieldItem.php which referenced in field.
3. Add this field to Search API index as the decimal field. My example (the select is "decimal")
4. Index it.
5. Add for Search API view for that index, you immediately get this error during AJAX modal submit, and after refresh the page, this will be broken and print the same error.
The problem leads to core Views
EntityField::defineOptions()There is code
$field_storage_definition = $this->getFieldStorageDefinition();which will getNULLfor computed field, since core views doesn't supports them and here the mess begins. SInce$field_storage_definitionisNULL, so the next line$field_type = $this->fieldTypePluginManager->getDefinition($field_storage_definition->getType());triggers this error.I'm not sure if this possible to fix, but I expected Search API views will bridge data from index to views frought own field by search api data type.
Comment #10
drunken monkeyThanks for re-opening and providing more detailed information!
With this, it was easy for me to reproduce the problem and come up with a sensible solution/workaround. (Just briefly stumbled because you forgot
$this->list[0] =incomputeValue().)Please see/test/review the attached patch!
Comment #11
drunken monkeySeems #2936737: Return computed fields in FieldAPIHandlerTrait::getFieldStorageDefinition() would let us support all options again for computed fields.
Comment #12
borisson_This looks like a good way of doing this until that core issue gets committed, after that one is in, we can find a way to find a support computed fields properly.
Comment #13
niklan+1 for RTBC
Looking forward to core support for computed fields.
Comment #14
niklanChange status to "Needs works" since it possible can be BC change.
I'll test it later.
Actually, Views do support computed fields and properties since 8.4. But they need to be more work done.
I want to test it, what happens if I do all of those requirements for Views and my computed field. If it will work, possible that some people use this approach and this patch will break their views and other stuff, since it force block computed fields to be used.
Comment #15
niklanAdditionally to computed field definition I applied
and created Views Field Plugin
The error still remains the same.
After applying the patch #10 the error has gone and I see values for both fields Views Plugin Field and Index Source.
Views Field Plugin doesn't affect the result at all when I tried to completely remove the hook and the field plugin. And the behavior remains the same (that's odd but not related to this issue).
Conclusion: This patch is safe to apply even if there are Views Filed Plugin and a corresponding hook, they are not affect computed fields at all and patch works in both cases the same. The result for both fields got from the search index.
Comment #17
drunken monkeyAlright, thanks for investigating!
As per the comment in
\Drupal\views\Plugin\views\field\EntityField::getFieldStorageDefinition()I think Core might have only fixed this for computed base fields, not all computed fields. Not sure, though.Anyways, if this is needed and approved, let’s commit it.
Thanks again, everyone!