Skip to content

Instantly share code, notes, and snippets.

@beardcoder
Forked from htuscher/IndexUserFunc.php
Created December 21, 2016 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beardcoder/7c4ca2f15841cb715a20cd65cc6ff6bb to your computer and use it in GitHub Desktop.
Save beardcoder/7c4ca2f15841cb715a20cd65cc6ff6bb 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment