From edcf2b33fca1cfe5c2b3d80d23c3589f37c545aa Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Mon, 11 Nov 2024 18:53:56 +0100 Subject: [PATCH] XML sitemap: out of stock sellable products are now in "sellableProducts" section - only products with "calculatedSellingDenied = TRUE" are now in "soldOutProducts" section --- src/Model/Sitemap/SitemapRepository.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Model/Sitemap/SitemapRepository.php b/src/Model/Sitemap/SitemapRepository.php index a01f19697f..d0b5e2dfcc 100644 --- a/src/Model/Sitemap/SitemapRepository.php +++ b/src/Model/Sitemap/SitemapRepository.php @@ -17,8 +17,6 @@ use Shopsys\FrameworkBundle\Model\Product\Flag\FlagRepository; use Shopsys\FrameworkBundle\Model\Product\Product; use Shopsys\FrameworkBundle\Model\Product\ProductRepository; -use Shopsys\FrameworkBundle\Model\Stock\ProductStock; -use Shopsys\FrameworkBundle\Model\Stock\StockDomain; class SitemapRepository { @@ -57,6 +55,7 @@ public function getSitemapItemsForListableProducts(DomainConfig $domainConfig, P AND fu.domainId = :domainId AND fu.main = TRUE', ) + ->andWhere('p.calculatedSellingDenied = FALSE') ->setParameter('productDetailRouteName', 'front_product_detail') ->setParameter('domainId', $domainConfig->getId()); @@ -177,20 +176,11 @@ public function getSitemapItemsForSoldOutProducts(DomainConfig $domainConfig, Pr AND fu.main = TRUE', ) ->andWhere('p.variantType != :variantTypeMain') + ->andWhere('p.calculatedSellingDenied = TRUE') ->setParameter('variantTypeMain', Product::VARIANT_TYPE_MAIN) ->setParameter('productDetailRouteName', 'front_product_detail') ->setParameter('domainId', $domainConfig->getId()); - $subquery = $queryBuilder->getEntityManager()->createQueryBuilder() - ->select('1') - ->from(ProductStock::class, 'ps') - ->join(StockDomain::class, 'sd', Join::WITH, 'ps.stock = sd.stock AND sd.domainId = :domainId') - ->where('ps.product = p') - ->having('SUM(ps.productQuantity) = 0'); - - $this->productRepository->addDomain($queryBuilder, $domainConfig->getId()); - $queryBuilder->andWhere('EXISTS(' . $subquery->getDQL() . ') AND (pd.saleExclusion = true)'); - return $this->getSitemapItemsFromQueryBuilderWithSlugField($queryBuilder); }