Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Use default options for swatch label matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Jacobs committed Oct 21, 2020
1 parent fde67f0 commit ebe714c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 3 additions & 2 deletions src/Model/Swatches/SwatchAttributeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit ebe714c

Please sign in to comment.