Skip to content

Commit

Permalink
Merge pull request #23 from findologic/SW-813_some_products_not_rende…
Browse files Browse the repository at this point in the history
…red_on_category_pages_v1

SW-813 Some products not rendered on category pages v1
  • Loading branch information
TobiasGraml11 authored Apr 22, 2024
2 parents e611d3a + 1b9e9f2 commit 5af06a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Export/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Constants
'manufacturer',
'manufacturer.translations',
'cover',
'visibilities',
];

public const VARIANT_ASSOCIATIONS = [
Expand Down
21 changes: 20 additions & 1 deletion src/Export/Search/AbstractProductSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

abstract class AbstractProductSearcher
{
protected const VISIBILITY_ALL = 30;

protected PluginConfig $pluginConfig;

protected AbstractProductCriteriaBuilder $productCriteriaBuilder;
Expand Down Expand Up @@ -107,7 +109,7 @@ protected function getCheapestProducts(ProductCollection $products): ProductColl
/** @var string[] $productPrice */
$cheapestVariantPrice = Utils::getCurrencyPrice($cheapestVariant->price, $currencyId);

if ($productPrice['gross'] === 0.0) {
if ($productPrice['gross'] === 0.0 || !$this->isProductVisible($product)) {
$realCheapestProduct = $cheapestVariant;
} else {
$realCheapestProduct = $productPrice['gross'] <= $cheapestVariantPrice['gross']
Expand Down Expand Up @@ -155,4 +157,21 @@ abstract protected function getCheapestChild(string $productId): ?ProductEntity;
abstract protected function getFirstVisibleChildId(string $productId): ?string;

abstract protected function getRealMainVariants(array $productIds): ProductCollection;

protected function isProductVisible(ProductEntity $product): bool
{
$salesChannelId = $this->exportContext->getSalesChannelId();

if ($product->active) {
foreach ($product->visibilities->getElements() as $productVisibility) {
if ($productVisibility->salesChannelId === $salesChannelId
&& $productVisibility->visibility >= self::VISIBILITY_ALL
) {
return true;
}
}
}

return false;
}
}

0 comments on commit 5af06a1

Please sign in to comment.