stape-io / gtm-server-side-magento-module

Stape GTM Server Side Magento Module
https://stape.io/apps
GNU General Public License v3.0
3 stars 3 forks source link

Product listing sorting not working when module is active #20

Closed michel334 closed 4 weeks ago

michel334 commented 1 month ago

The product listing sorting is not working when module stape/gtm-server-side-magento-module is active

stape/gtm-server-side-magento-module: version 1.0.16 Magento: 2.4.4-p9 Elasticsearch 7

stape plugin file which seems to create the problem \vendor\stape\gtm-server-side-magento-module\ViewModel\Category.php

public function prepareItems()

This call:

$collection = $productList->getLoadedProductCollection();

Messes up the sorting of the product categorie pages

Some relevant GitHub issues https://github.com/magento/magento2/issues/4132 Search for: ARGH! Kill me please...

sorteren

Bukashk0zzz commented 1 month ago

Hi,

Thanks for reporting we will take a look.

chaikovskyia commented 1 month ago

Hi @michel334 , thank you for the report. Could you, please, clarify if that happens on clean Magento or you use some specific theme as I cannot reproduce it on clean Magento installation. We did have such an issue on earlier version of the module, however, we now create new instance of \Magento\Catalog\Block\Product\ListProduct in our module so it is not supposed to overlap with the instance used on the category page.

michel334 commented 1 month ago

Hi chaikovskyia, Thanks for checking. I have all themes disabled and the sorting problem persists. When i disable the stape module in Magento backend the sorting works as expected. I attached some more screenshots. The sorting is on the position field of the products attached to a categorie:

sorting

On the frontend when i click on the up/down arrow of sorting position, nothing happens with stape.io module enabled. When i disable the module the sorting works as expected. We have the latest version of the module (1.0.16)

sorting-frontend

I hope this clariefies the issue a bit. Kind regards, Michel

chaikovskyia commented 1 month ago

@michel334 , thank you for the details. I'll re-check it.

chaikovskyia commented 4 weeks ago

@michel334 , I still cannot reproduce the bug on clean Magento 2 installation. I see you use other third party modules, maybe some of the modules impacts the sorting behavior as well.

michel334 commented 4 weeks ago

Hi chaikovskyia You are correct, there was another module that calls: public function afterGetLoadedProductCollection(\Magento\Catalog\Block\Product\ListProduct $subject, $resultCollection)

I added this code to that module, the same code that is in vendor\stape\gtm-server-side-magento-module\ViewModel\Category.php

    /** @var \Magento\Catalog\Block\Product\ListProduct $productList */
    $productList = $this->layout->createBlock(\Magento\Catalog\Block\Product\ListProduct::class);
    $productList->getToolbarBlock()->setCollection($resultCollection);

The sorting is working correctly now thanks for your assistance.

chaikovskyia commented 4 weeks ago

You're always welcome ;)