Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TYPO3 Solr userFunc IndexQueue
<?php
namespace Vendor\Extension\Solr\UserFunc;
class IndexUserFunc
{
/**
* This value is automatically inserted by userFunc handling
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
public $cObj;
/**
* @param mixed $content
* @param array $conf
* @return string
*/
public function doSomething($content, $conf) {
/** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
$db = $GLOBALS['TYPO3_DB'];
/** @var array $record */
$record = $this->cObj->data;
//$conf contains the configuration from typoscript index queue of this field. E.g. someParam
$relatedRecord = $db->exec_SELECTgetSingleRow('title', 'mytable', 'local_uid = ' . $record['uid'] . ' AND foo = ' . $conf['someParam.']['myValue']);
return $relatedRecord['title'];
}
}
plugin.tx_solr.index.queue.myType = 1
plugin.tx_solr.index.queue.myType {
table = tx_vendor_domain_model_product
fields {
title = title
# more fields
myField_stringS = USER
myField_stringS.userFunc = Vendor\Extension\Solr\UserFunc\IndexUserFunc->doSomething
myField_stringS.someParam < lib.my.stuff
}
}
@webfacer

This comment has been minimized.

Copy link

commented Jul 14, 2017

does this work, because i have the same configuration as you, but solr throws error messages when trying like you.
also found this that userFunc doesn´t work for queue https://twitter.com/Markus306/status/626457726323924992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.