Open jonnsn opened 3 months ago
I can confirm the error described, but unfortunately the problem is more complex. Removing the line mentioned unfortunately generates errors in other scenarios, I'm afraid we'll have to refactor SOLR_RELATION.
I can't remember the background of the change back then, a special format is used in the tests, if on purpose or by mistake, I can't say spontaneously.
In the meantime, the definition of an additional segment could be used as a workaround:
foreignLabelField = parent.title.description
@dkd-friedrich Thanks for investigating. I do not really get the workaround. I want parent.description. Your Workaround suggests to add ".title" in that path, so it becomes parent.title.description. Right? This does not seem to work for me unfortunately.
@dkd-friedrich Thanks for investigating. I do not really get the workaround. I want parent.description. Your Workaround suggests to add ".title" in that path, so it becomes parent.title.description. Right? This does not seem to work for me unfortunately.
@jonnsn ok, my test case might be wrong.
Unfortunately, I can't dive deeper into the topic at the moment, but I have pushed my extended integration test, perhaps that will help: => https://github.com/TYPO3-Solr/ext-solr/commit/f91b81b15a1c18dd683a660b4fb723c7e24ad163
In my test case, it was sufficient to use "parent.xxx.description" instead of "parent.description" for "foreignLabelField".
@dkd-friedrich Thanks for your hints.
I can confirm your Workaround works - if there is only one Item in $relatedRecords.
If you extend my steps to reproduce from above by replacing steps 3 and 4 with the following:
then it will work (with your workaround active) for the first of the categories, but every following record will have title instead of description in the index. This is because $this->configuration['foreignLabelField'] is set to the remaining part already and therefore does not contain any '.' anymore on the next foreach ($relatedRecords as $record)
run.
So combining it with your workaround I can patch the code quick and dirty as follows to get it working for me:
\ApacheSolrForTypo3\Solr\ContentObject\Relation::getRelatedItemsFromMMTable
replace
foreach ($relatedRecords as $record) {
with
$originalForeignLabelField = $this->configuration['foreignLabelField'];
foreach ($relatedRecords as $record) {
$this->configuration['foreignLabelField'] = $originalForeignLabelField;
unfortunately I could not get the tests to work in my solr-ddev-site instance, so I could not test the change...
Describe the bug A field of type SOLR_RELATION with enableRecursiveValueResolution = 1 and having a foreignLabelField with a subproperty (dot-notation) will always resolve the Label Field defined via TCA instead of the field, defined in the Typoscript property foreignLabelField.
To Reproduce Steps to reproduce the behavior:
Expected behavior the SOLR Field "content" for the modified record should contain the description of "cat 1" entered in step 2.
Used versions (please complete the following information): (from current solr-ddev-site)
Additional context removing ext:solr/Classes/ContentObject/Relation.php:178
unset($this->configuration['foreignLabelField']);
solves the problem. But I am unsure why this line is needed. Thats why I did not provide a patch. The line was added with https://github.com/TYPO3-Solr/ext-solr/pull/3484/files.