Preconditions (*)
- Magento2.3.4
- Magento 2.4-develop
Steps to reproduce (*)
- Add a custom block which uses or extends Magento\Catalog\Block\Product\ListProduct.php.
- For the template get all the products using $block->getLoadedProductCollection();
- layout - catalog_category_view.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\ListProduct" name="product.detail.sorttest" template="Vendor_Module::schema.phtml" before="-"/>
</referenceContainer>
</body>
</page>
- contents of the block file.
<?php $products = $block->getLoadedProductCollection();
echo "already here"; ?>
<?php if($products->count()) : ?>
<?php foreach($products as $product): ?>
<div> <?php echo $product->getId(); ?> </div>
<?php endforeach; ?>
<?php endif; ?>
Expected result (*)
- Product Sorting in category page should work.
Actual result (*)
- Product Sort does not work.

This used to work on Magento 2.1.10 .
I am using the given method to get all the products currently visible in the category page. Can anyone suggest any other method instead ?
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
This used to work on Magento 2.1.10 .
I am using the given method to get all the products currently visible in the category page. Can anyone suggest any other method instead ?