Skip to content

Commit

Permalink
XML sitemap: out of stock sellable products are now in "sellableProdu…
Browse files Browse the repository at this point in the history
…cts" section

- only products with "calculatedSellingDenied = TRUE" are now in "soldOutProducts" section
  • Loading branch information
vitek-rostislav committed Nov 11, 2024
1 parent 24a6a13 commit edcf2b3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/Model/Sitemap/SitemapRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit edcf2b3

Please sign in to comment.