Skip to content

Instantly share code, notes, and snippets.

@htuscher
Last active August 31, 2017 12:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save htuscher/04b367c1957a1e599504 to your computer and use it in GitHub Desktop.
Save htuscher/04b367c1957a1e599504 to your computer and use it in GitHub Desktop.
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
Copy link

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