From ebe714c3e14327bf6aa54766eb0662fafcc145fd Mon Sep 17 00:00:00 2001 From: Edwin Jacobs Date: Wed, 21 Oct 2020 10:43:50 +0200 Subject: [PATCH] Use default options for swatch label matching --- CHANGELOG.md | 6 ++++++ src/Model/Swatches/SwatchAttributeResolver.php | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60dc330c..e76625f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.0.2 +Added swatch resolver for derived color filters in tweakwise, this fixes [#126](https://github.com/EmicoEcommerce/Magento2Tweakwise/issues/126) +Possible issues with this: It is unclear from the navigator response which magento attribute (if any) was used to created the derived property, +as such we cannot know which swatches to load. We do a guess based on the swatch labels but this could lead to missing swatches. In order to find a match +for derived swatch with label "Red" in tweakwise magento needs to have a swatch attribute with an option labeled "Red", case sensitive. + ## 3.0.1 BugFix: Release 3.0.0 introduced an error where the magento autocomplete template was loaded instead of the tweakwise autocomplete template. diff --git a/src/Model/Swatches/SwatchAttributeResolver.php b/src/Model/Swatches/SwatchAttributeResolver.php index a6404db8..ecc02da5 100644 --- a/src/Model/Swatches/SwatchAttributeResolver.php +++ b/src/Model/Swatches/SwatchAttributeResolver.php @@ -11,6 +11,7 @@ use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Eav\Api\AttributeRepositoryInterface; use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface; +use Magento\Eav\Model\Entity\Attribute\Source\Table; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Swatches\Model\SwatchAttributeCodes; use Magento\Swatches\Model\SwatchAttributeType; @@ -141,8 +142,8 @@ protected function getSwatchMap(): array // We cannot resolve an attribute without source. continue; } - /** @var SourceInterface $source */ - $options = $source->getAllOptions(); + /** @var Table $source */ + $options = $source->getAllOptions(true, true); $optionLabels = array_column($options, 'label'); $optionValues = array_column($options, 'value');