src/Core/Content/Sitemap/Provider/AbstractUrlProvider.php line 40

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Sitemap\Provider;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Content\Sitemap\Struct\UrlResult;
  5. use Shopware\Core\Framework\Log\Package;
  6. use Shopware\Core\Framework\Uuid\Uuid;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. #[Package('sales-channel')]
  9. abstract class AbstractUrlProvider
  10. {
  11.     /**
  12.      * This function should return the decorated core service.
  13.      * This ensures that when new functions are implemented in this class, decorations will continue to work
  14.      */
  15.     abstract public function getDecorated(): AbstractUrlProvider;
  16.     abstract public function getName(): string;
  17.     abstract public function getUrls(SalesChannelContext $contextint $limit, ?int $offset null): UrlResult;
  18.     /**
  19.      * @param list<string> $ids
  20.      *
  21.      * @return list<array{foreign_key: string, seo_path_info: string}>
  22.      */
  23.     protected function getSeoUrls(array $idsstring $routeNameSalesChannelContext $contextConnection $connection): array
  24.     {
  25.         $sql 'SELECT LOWER(HEX(foreign_key)) as foreign_key, seo_path_info
  26.                     FROM seo_url WHERE foreign_key IN (:ids)
  27.                      AND `seo_url`.`route_name` =:routeName
  28.                      AND `seo_url`.`is_canonical` = 1
  29.                      AND `seo_url`.`is_deleted` = 0
  30.                      AND `seo_url`.`language_id` =:languageId
  31.                      AND (`seo_url`.`sales_channel_id` =:salesChannelId OR seo_url.sales_channel_id IS NULL)';
  32.         /** @var list<array{foreign_key: string, seo_path_info: string}> $result */
  33.         $result $connection->fetchAllAssociative(
  34.             $sql,
  35.             [
  36.                 'routeName' => $routeName,
  37.                 'languageId' => Uuid::fromHexToBytes($context->getLanguageId()),
  38.                 'salesChannelId' => Uuid::fromHexToBytes($context->getSalesChannelId()),
  39.                 'ids' => Uuid::fromHexToBytesList(array_values($ids)),
  40.             ],
  41.             [
  42.                 'ids' => Connection::PARAM_STR_ARRAY,
  43.             ]
  44.         );
  45.         return $result;
  46.     }
  47. }