Adds functionality to publish and retrieve sitemap data from storage (Redis). The data is stored in DB and synced to Redis for faster retrieval.
⚠️ This package does not support Spryker setups that have different Redis instances for different stores
composer require valantic-spryker/sitemap-storage
- Since this module is under
ValanticSpryker
namespace, make sure that inconfig_default
:$config[KernelConstants::CORE_NAMESPACES]
has the namespace$config[KernelConstants::PROJECT_NAMESPACES]
has the namespace
- Run
console propel:install
to install theval_sitemap_storage
table.
protected function getProcessorMessagePlugins(Container $container): array
{
return [
// ...
SitemapStorageConfig::PUBLISH_SITEMAP => new EventQueueMessageProcessorPlugin(),
SitemapStorageConfig::SITEMAP_SYNC_STORAGE_QUEUE => new SynchronizationStorageQueueMessageProcessorPlugin(),
];
}
Add
ValanticSpryker\Zed\SitemapStorage\Communication\Plugin\Event\Subscriber\SitemapStorageEventSubscriber
in
\Pyz\Zed\Event\EventDependencyProvider::getEventSubscriberCollection
to handle all publish and unpublish events:
public function getEventSubscriberCollection(): EventSubscriberCollectionInterface
{
$eventSubscriberCollection = parent::getEventSubscriberCollection();
// ...
$eventSubscriberCollection->add(new SitemapStorageEventSubscriber());
}
Since SitemapStorageClient
implements the same interface as SitemapClient
, both clients can be used interchangeably.
So to make the main Sitemap module retrieve data from Redis, the SitemapStorageClient
needs to be switched with regular SitemapClient
in:
\ValanticSpryker\Yves\Sitemap\SitemapDependencyProvider
protected function addSitemapClient(Container $container): void
{
$container->set(static::CLIENT_SITEMAP, static function (Container $container): SitemapClientInterface {
return $container->getLocator()->sitemapStorage()->client();
});
}
Now the SitemapStorageClient
is used instead, and it takes care of retrieving the data from Redis and mapping to correct transfer.
protected function getPyzPublishQueueConfiguration(): array
{
return [
// [...]
SitemapStorageConfig::PUBLISH_SITEMAP,
];
}
protected function getPyzSynchronizationQueueConfiguration(): array
{
return [
// [...]
SitemapStorageConfig::SITEMAP_SYNC_STORAGE_QUEUE,
];
}