EmicoEcommerce / Magento2Tweakwise-archived

Magento 2 module for Tweakwise integration
Other
9 stars 25 forks source link

Color swatches not visible when using 'Afgeleide eigenschap' #126

Closed dvdhaar closed 3 years ago

dvdhaar commented 4 years ago

Issue Brief

No color swatches are visible at the frontend when using the 'Afgeleide eigenschap' from type 'Vervangen'.

Environment

Steps to reproduce

  1. Export multiple configurable products with multiple children to Tweakwise.
  2. Set up different colors for Red on multiple products (e.g. light red, dark red etc.)
  3. Configure 'afgeleide eigenschap' from type 'vervangen' filter in Tweakwise and map the colors to the main color 'Red'.

Actual result

No color swatches are visible in the frontend of Magento Correct display of color filter in the Demo navigator

Expected result

Show the correct color swatches for the main colors / mapped colors.

Schermafbeelding 2020-09-25 om 13 46 32 Schermafbeelding 2020-09-25 om 13 48 04
edwinljacobs commented 4 years ago

I'll look into it, I hope to have an update today.

With kind regards

edwinljacobs commented 4 years ago

Hi,

We do have a "fix" for this, however it is rather error prone. The point being that it is unclear in the navigator response which magento attribute was used to create the derived property. Below is a navigator response extract for a derived color property

<facetsettings>
<facetid>93</facetid>
<isvisible>true</isvisible>
<attributename>kleurenfilter</attributename>
<urlkey>kleurenfilter</urlkey>
<title>kleurenfilter</title>
<iscollapsible>true</iscollapsible>
<iscollapsed>false</iscollapsed>
<nrofshownattributes>15</nrofshownattributes>
<expandtext>Meer tonen</expandtext>
<collapsetext>Minder tonen</collapsetext>
<ismultiselect>true</ismultiselect>
<showselectedfirst>true</showselectedfirst>
<multiselectlogic>or</multiselectlogic>
<selectiontype>color</selectiontype>
<nrofcolumns>1</nrofcolumns>
<isnrofresultsvisible>true</isnrofresultsvisible>
<isinfovisible>false</isinfovisible>
<infotext/>
<containsclickpoints>false</containsclickpoints>
<containsbuckets>false</containsbuckets>
<source>AFGELEID</source>
<prefix xsi:nil="true"/>
<postfix xsi:nil="true"/>
<cssclass xsi:nil="true"/>
</facetsettings>

We cannot see which magento attribute is used to create the derived property. Based on the filter items we are able to sort of guess which swatch attribute was used and the current solution uses that

<attributes>
<attribute alternatesortorder="0">
<title>Blue</title>
<isselected>true</isselected>
<nrofresults>7</nrofresults>
<attributeid xsi:nil="true"/>
<url>
<![CDATA[ ?tn_cid=1000123&tn_fk_kleurenfilter=Yellow ]]>
</url>
<imagetag/>
<children/>
</attribute>
<attribute alternatesortorder="1">
<title>Yellow</title>
<isselected>true</isselected>
<nrofresults>2</nrofresults>
<attributeid xsi:nil="true"/>
<url>
<![CDATA[ ?tn_cid=1000123&tn_fk_kleurenfilter=Blue ]]>
</url>
<imagetag/>
<children/>
</attribute>
</attributes>

We decided to combine all filter attribute titles (attribute > title in the above xml) as an array of labels. Then for each swatch attribute we get its options and check if there are any matching labels. We then use the attribute which has the most matching labels. This is error prone and could lead to missing filter items, as it depends on the configuration / labels in the navigator.

However I do not see any other way to resolve this issue. In your navigator instance screenshot we see that you replace color values i.e. "2nd red" > "Red", to use this fix there must be a swatch attribute with an option labelled Red (case sensitive) in magento otherwise we cannot find the corresponding swatch.

If it is an option for you, you could check branch: issue/126-derived-swatchfilter it has this fix included.

With kind regards

dvdhaar commented 4 years ago

Thanks! Works well. The only issue I can discover is the mismatch on translations. Is it possible to match with the Admin labels? So we can use 'Red' voor UK store front and 'Rood' for the NL store front.

edwinljacobs commented 4 years ago

Nice to hear that it works :) Ill check the last bit. It could be that the update is somewhat later due to vacation.

dvdhaar commented 4 years ago

No problem! Now solved it by adding all color translations in Tweakwise: Original: Black Replacements: Black, Zwart

edwinljacobs commented 4 years ago

Hi,

Due to vacation and some stuff going on I hope to release this next week.

With kind regards

edwinljacobs commented 3 years ago

Just a last check, you want to match against the default options from the swatch attributes right? So:

if (!$swatchAttribute->usesSource() || !($source = $swatchAttribute->getSource())) {
                // We cannot resolve an attribute without source.
                continue;
            }
            /** @var Table $source */
            $options = $source->getAllOptions(true, true);

The second "true" in

$options = $source->getAllOptions(true, true);

stands for "defaultValues" (get default values: true or false)

Is that correct? If so i'll release today.

With kind regards

dvdhaar commented 3 years ago

That's right!

edwinljacobs commented 3 years ago

This has been released in v3.0.2 (https://github.com/EmicoEcommerce/Magento2Tweakwise/releases/tag/v3.0.2)

With kind regards