From a2799a675864bdf668b713760acb81964dddbdc4 Mon Sep 17 00:00:00 2001 From: Hung Mac Date: Fri, 1 Jul 2022 14:17:30 +0700 Subject: [PATCH] Fix to ignored the product don't have combinable --- CHANGELOG_de-DE.md | 1 + CHANGELOG_en-GB.md | 1 + src/Storefront/Page/ProductListingConfigurationLoader.php | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index e00a8b9..d457e06 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,6 +1,7 @@ # 1.1.0 - Erweiterung - [Issue #1](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/1) Zeige auch Varianten, die nicht auf Lager sind - [Issue #2](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/2) Ausblenden von geteilten Varianten +- [Issue #6](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/6) Ignoriert, dass das Produkt nicht kombinierbar ist # 1.0.0 - Erste Veröffentlichung - Variantenschalter auf der Produktliste anzeigen diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index 02a2ce1..a585a17 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,6 +1,7 @@ # 1.1.0 - Enhancement - [Issue #1](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/1) Show also variants which are out of stock - [Issue #2](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/2) Hide split variants +- [Issue #6](https://github.com/Shape-and-Shift/shopware-variant-switch/issues/6) Ignored the product don't have combinable # 1.0.0 - First release - Show variant switch on product listing card diff --git a/src/Storefront/Page/ProductListingConfigurationLoader.php b/src/Storefront/Page/ProductListingConfigurationLoader.php index 47fe6f5..513c56c 100644 --- a/src/Storefront/Page/ProductListingConfigurationLoader.php +++ b/src/Storefront/Page/ProductListingConfigurationLoader.php @@ -43,6 +43,9 @@ public function loadListing(ProductCollection $products, SalesChannelContext $co })); $allCombinations = $this->loadCombinations($productIds, $context->getContext()); + if (\count($allCombinations) === 0) { + return; + } /** @var SalesChannelProductEntity $product */ foreach ($products as $product) { @@ -58,6 +61,10 @@ public function loadListing(ProductCollection $products, SalesChannelContext $co $groups = $this->sortSettings($productSetting, $product); + if (!array_key_exists($product->getParentId(), $allCombinations)) { + continue; + } + $combinations = $allCombinations[$product->getParentId()]; $current = $this->buildCurrentOptions($product, $groups);