EmicoEcommerce / Magento2Tweakwise-archived

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

Grouped template items not showing #51

Closed govereem closed 4 years ago

govereem commented 6 years ago

I think tweakwise changed the result given and changed the xml structure. vendor/emico/tweakwise/src/Model/Client.php function doRequest returns the wrong array structure after xmlToArray. The upsell / crosssell collection expects an array return from doRequest items->item[] But will return recommendation->items->item[], the collection will have no records.

URL: http://navigator-group1.tweakwise.com/recommendations/grouped/..../...../groupname

Magento 2.2.4 Tweakwise Version 1.3.2 php 7.1

For now fixed it with a dirty solution In the doRequest added to the and before $this->responseFactory->create($request, $result);

        if(isset($result['recommendation'])) {
            $updatedResult=[];
            foreach($result['recommendation'] as $key => $items) {
                foreach($items['items'] as $itemArr) {
                    if(isset($itemArr['itemno'])) {
                        $updatedResult['items']['item'][] = $itemArr;
                    } else {
                        foreach($itemArr as $item) {
                            $updatedResult['items']['item'][] = $item;
                        }
                    }
                }
            }
            return $this->responseFactory->create($request, $updatedResult);
        }

Result grouped:

<recommendations xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<recommendation>
<id>12</id>
<name>Upsell / Cirkelzagen (Spanklemmen)</name>
<items>
<item>
<itemno>1000171667</itemno>
<title>Festool SYS-MFT Fixing-Set Limited Edition</title>
<brand/>
<price>247.89</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000154653</itemno>
<title>Festool FS-HZ 160 Snelspanklem 491594</title>
<brand/>
<price>41.28</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
</items>
</recommendation>
<recommendation>
<id>421</id>
<name>Upsell / Cirkelzagen (Foudraals) </name>
<items>
<item>
<itemno>1000154650</itemno>
<title>Festool FS-BAG Foudraal 466357</title>
<brand/>
<price>47.89</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
</items>
</recommendation>
<recommendation>
<id>422</id>
<name>Upsell / Cirkelzagen (Parallelaanslagen)</name>
<items>
<item>
<itemno>1000154086</itemno>
<title>Festool FS-PS/PSB 300 Geleideaanslag 490031</title>
<brand/>
<price>12.355</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
</items>
</recommendation>
</recommendations>

Result product template (That works!):

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<recommendation xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<items>
<item>
<itemno>1000153649</itemno>
<title>
Festool Speciaal Cirkelzaagblad 160x2,2x20 TF48 496308
</title>
<brand/>
<price>61.94</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000167623</itemno>
<title>
Festool Diamant Cirkelzaagblad 160x2,2x20 DIA4 201910
</title>
<brand/>
<price>123.925</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000153653</itemno>
<title>
Festool Fijngetand Cirkelzaagblad 160x2,2x20 W48 491952
</title>
<brand/>
<price>41.28</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000153650</itemno>
<title>
Festool Speciaal Cirkelzaagblad 160x2,2x20 TF48 496306
</title>
<brand/>
<price>68.553</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000153652</itemno>
<title>
Festool Universeel Cirkelzaagblad 160x2,2x20 W28 496302
</title>
<brand/>
<price>37.15</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000153651</itemno>
<title>
Festool Standaard Cirkelzaagblad 160x2,2x20 W18 768129
</title>
<brand/>
<price>30.537</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000163955</itemno>
<title>
Festool Panther Cirkelzaagblad 160x1,8x20 PW12 500460
</title>
<brand/>
<price>45.41</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
<item>
<itemno>1000163954</itemno>
<title>
Festool Standaard Cirkelzaagblad 160x1,8x20 W18 500458
</title>
<brand/>
<price>33.016</price>
<url i:nil="true"/>
<image i:nil="true"/>
<labels i:nil="true"/>
<attributes/>
</item>
</items>
</recommendation>
edwinljacobs commented 5 years ago

Hi,

Late reply but there has been some development on this issue. You could try and test branch issue/117647-grouped-recommendations.

Indeed the issue is that the recommendation response varies on the type of request.

With kind regard

edwinljacobs commented 4 years ago

Hello,

This should be fixed in v2.1.1 https://github.com/EmicoEcommerce/Magento2Tweakwise/releases/tag/v2.1.1

If you feel this is incorrect, feel free to reopen this.

With kind regards