How to fix the Magento 2.4.5 Layered Navigation showing incorrect results issue?

How to fix the Magento 2.4.5 Layered Navigation showing incorrect results issue?

After upgrading Magento to version 2.4.5 you can see the error:

TypeError: Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplier::categoryProductByCustomSortOrder(): Argument #1 ($categoryId) must be of type int, array given

Moreover, in Magento 2.4.5, if you have Display Out of Stock Products setting enabled, the layered navigation will not work correctly.

This bug is related to recent Magento changes and affects custom extensions such as Amasty Improved Layered Navigation.

How to fix the Magento 2.4.5 issue with Layered Navigation?

Magento appears to fix this bug only in the next release, but you don't have to wait for their update because we have already developed a free fixpack to resolve this issue.

If you are an Amasty customer, you can fix this error by installing additional package from our private repository:

composer require amasty/module-mage-2.4.5-fix

But this case can be reproduced without our extension. This is why we made the package public.

Is the module required for other Magento versions?

The extension was developed for Magento 2.4.5 specifically. Moreover, in newer versions, the issue with the catalog display has been resolved by the Adobe team. Therefore, the Amasty_Mage245Fix module is not required and should be removed after upgrading the Magento to version 2.4.6 and higher to eliminate issues with product listing functioning.