Skip to content

Commit fc04ea7

Browse files
authored
Add "Disable Product Stream Indexer" checker (#299)
* Add "Disable Product Stream Indexer" checker * Don't activate indexing for versions that do not have the parameter
1 parent b1f6b8d commit fc04ea7

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker;
6+
7+
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
8+
use Frosh\Tools\Components\Health\HealthCollection;
9+
use Frosh\Tools\Components\Health\SettingsResult;
10+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
11+
12+
class ProductStreamIndexingChecker implements PerformanceCheckerInterface, CheckerInterface
13+
{
14+
public function __construct(
15+
#[Autowire(param: 'shopware.product_stream.indexing')]
16+
private readonly bool $productStreamIndexingEnabled,
17+
) {}
18+
19+
public function collect(HealthCollection $collection): void
20+
{
21+
if ($this->productStreamIndexingEnabled) {
22+
$collection->add(
23+
SettingsResult::info(
24+
'product-stream-indexing',
25+
'Product Stream Indexing',
26+
'enabled',
27+
'disabled',
28+
'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-product-stream-indexer',
29+
),
30+
);
31+
}
32+
}
33+
}

src/DependencyInjection/SymfonyConfigCompilerPass.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,20 @@ public function process(ContainerBuilder $container): void
2424
$container->setParameter('frosh_tools.queue_connection', 'unknown://default');
2525
}
2626

27-
if (!$container->hasParameter('shopware.cache.cache_compression_method')) {
28-
$container->setParameter('shopware.cache.cache_compression_method', false);
29-
}
30-
31-
if (!$container->hasParameter('shopware.cart.compression_method')) {
32-
$container->setParameter('shopware.cart.compression_method', false);
33-
}
34-
35-
if (!$container->hasParameter('shopware.cache.tagging.each_config')) {
36-
$container->setParameter('shopware.cache.tagging.each_config', true);
37-
}
38-
39-
if (!$container->hasParameter('shopware.cache.tagging.each_snippet')) {
40-
$container->setParameter('shopware.cache.tagging.each_snippet', true);
41-
}
42-
43-
if (!$container->hasParameter('shopware.cache.tagging.each_theme_config')) {
44-
$container->setParameter('shopware.cache.tagging.each_theme_config', true);
45-
}
46-
47-
if (!$container->hasParameter('framework.secrets.enabled')) {
48-
$container->setParameter('framework.secrets.enabled', true);
27+
$defaultParameters = [
28+
'framework.secrets.enabled' => true,
29+
'shopware.cache.cache_compression_method' => false,
30+
'shopware.cache.tagging.each_config' => true,
31+
'shopware.cache.tagging.each_snippet' => true,
32+
'shopware.cache.tagging.each_theme_config' => true,
33+
'shopware.cart.compression_method' => false,
34+
'shopware.product_stream.indexing' => false,
35+
];
36+
37+
foreach ($defaultParameters as $parameter => $value) {
38+
if (!$container->hasParameter($parameter)) {
39+
$container->setParameter($parameter, $value);
40+
}
4941
}
5042
}
5143
}

0 commit comments

Comments
 (0)