Created
February 12, 2015 15:55
-
-
Save htuscher/781b51a2126b791d37d9 to your computer and use it in GitHub Desktop.
TYPO3 Solr Custom language fallback per index queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Copyright notice | |
* | |
* (c) Onedrop Solutions GmbH & Co. KG, www.1drop.de | |
* | |
* @author Hans Höchtl <[email protected]> | |
* | |
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later | |
*/ | |
namespace ODS\OdsSolr\Indexer; | |
/** | |
* Class FallbackLanguageIndexer | |
* | |
* @package ODS\OdsSolr\Indexer | |
*/ | |
class FallbackLanguageIndexer extends \Tx_Solr_IndexQueue_Indexer { | |
/** | |
* Converts an item array (record) to a Solr document by mapping the | |
* record's fields onto Solr document fields as configured in TypoScript. | |
* | |
* @param \Tx_Solr_IndexQueue_Item $item An index queue item | |
* @param integer $language Language Id | |
* @return \Apache_Solr_Document The Solr document converted from the record | |
*/ | |
protected function itemToDocument( \Tx_Solr_IndexQueue_Item $item, $language = 0 ) { | |
$solrConfiguration = \Tx_Solr_Util::getSolrConfigurationFromPageId($item->getRootPageUid(), TRUE, $language); | |
$indexingConfiguration = $solrConfiguration['index.']['queue.'][$item->getIndexingConfigurationName() . '.']; | |
if (isset($indexingConfiguration['indexer.']) && | |
isset($indexingConfiguration['indexer.']['doLanguageFallback']) && | |
$indexingConfiguration['indexer.']['doLanguageFallback'] == TRUE) { | |
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess']['overrideLanguageFallback'] = function(&$params, &$ref){ | |
$ref->config['config']['sys_language_overlay'] = 1; | |
}; | |
} | |
return parent::itemToDocument($item, $language); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugin.tx_solr.index.queue { | |
amiradaProducts = 1 | |
amiradaProducts { | |
table = tx_odsfoo_domain_model_bar | |
indexer = ODS\OdsSolr\Indexer\FallbackLanguageIndexer | |
indexer { | |
doLanguageFallback = 1 | |
} | |
fields { | |
title = title | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment