sulu/SuluArticleBundle

Add search index configuration

mgwestwerk opened this issue · 1 comments

Q A
Bug? no
New Feature? yes
SuluArticleBundle Version 2.0
Sulu Version 2.0.6

Actual Behavior

Articles do not appear in search results provided by the SearchBundle.

Expected Behavior

Articles should be among the possible search results.

Possible Solutions

Prepend for the article index to the sulu_search configuration

Related Issues

sulu/sulu#2811 is necessary in order to include articles in frontend searches
#468 to support multiple article types

Just stumbled upon this again and want to add some context here. In theor, solving this hould be as easy as adding the following lines to the SuluArticleExtension:

$container->prependExtensionConfig(
    'sulu_search',
    [
        'indexes' => [
            'article' => [
                'name' => 'sulu_article.articles',
                'icon' => 'su-newspaper',
                'view' => [
                    'name' => ArticleAdmin::EDIT_FORM_VIEW,
                    'result_to_view' => ['id' => 'id', 'locale' => 'locale'],
                ],
                'security_context' => ArticleAdmin::SECURITY_CONTEXT,
            ],
        ],
    ]
);

Unfortunately, this does not work because the ArticleAdmin::EDIT_FORM_VIEW is not registered as view. Instead, the bundle registers a separate EDIT_FORM_VIEW for each article type:

$viewCollection->add(
$this->viewBuilderFactory->createResourceTabViewBuilder(static::EDIT_FORM_VIEW . '_' . $typeKey, '/articles/:locale/' . $typeKey . '/:id')
->setResourceKey('articles')
->addLocales($locales)
->setBackView(static::LIST_VIEW . '_' . $typeKey)
->setTitleProperty('title')
);

This problem is similar to the problem that prevents the implementation of deep links in the bundle at the moment: #468