Skip to content

Commit

Permalink
Add "Disable Product Stream Indexer" checker (#299)
Browse files Browse the repository at this point in the history
* Add "Disable Product Stream Indexer" checker

* Don't activate indexing for versions that do not have the parameter
  • Loading branch information
M-arcus authored Dec 6, 2024
1 parent b1f6b8d commit fc04ea7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker;

use Frosh\Tools\Components\Health\Checker\CheckerInterface;
use Frosh\Tools\Components\Health\HealthCollection;
use Frosh\Tools\Components\Health\SettingsResult;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class ProductStreamIndexingChecker implements PerformanceCheckerInterface, CheckerInterface
{
public function __construct(
#[Autowire(param: 'shopware.product_stream.indexing')]
private readonly bool $productStreamIndexingEnabled,
) {}

public function collect(HealthCollection $collection): void
{
if ($this->productStreamIndexingEnabled) {
$collection->add(
SettingsResult::info(
'product-stream-indexing',
'Product Stream Indexing',
'enabled',
'disabled',
'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-product-stream-indexer',
),
);
}
}
}
36 changes: 14 additions & 22 deletions src/DependencyInjection/SymfonyConfigCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,20 @@ public function process(ContainerBuilder $container): void
$container->setParameter('frosh_tools.queue_connection', 'unknown://default');
}

if (!$container->hasParameter('shopware.cache.cache_compression_method')) {
$container->setParameter('shopware.cache.cache_compression_method', false);
}

if (!$container->hasParameter('shopware.cart.compression_method')) {
$container->setParameter('shopware.cart.compression_method', false);
}

if (!$container->hasParameter('shopware.cache.tagging.each_config')) {
$container->setParameter('shopware.cache.tagging.each_config', true);
}

if (!$container->hasParameter('shopware.cache.tagging.each_snippet')) {
$container->setParameter('shopware.cache.tagging.each_snippet', true);
}

if (!$container->hasParameter('shopware.cache.tagging.each_theme_config')) {
$container->setParameter('shopware.cache.tagging.each_theme_config', true);
}

if (!$container->hasParameter('framework.secrets.enabled')) {
$container->setParameter('framework.secrets.enabled', true);
$defaultParameters = [
'framework.secrets.enabled' => true,
'shopware.cache.cache_compression_method' => false,
'shopware.cache.tagging.each_config' => true,
'shopware.cache.tagging.each_snippet' => true,
'shopware.cache.tagging.each_theme_config' => true,
'shopware.cart.compression_method' => false,
'shopware.product_stream.indexing' => false,
];

foreach ($defaultParameters as $parameter => $value) {
if (!$container->hasParameter($parameter)) {
$container->setParameter($parameter, $value);
}
}
}
}

0 comments on commit fc04ea7

Please sign in to comment.