Skip to main content
1 of 2

To modify product collection before rendering category page follow these steps:

  1. Override Magento\Catalog\Block\Product\ListProduct

  2. In function _getProductCollection after if statement insert your code:

    $collection = $this->_productCollection; foreach ($collection as $k => $product){ // Here goes your code to modify product // For example:

    $collection->removeItemByKey($k);// Remove original item from collection } $collection->setOrder('position','ASC');// Reorder collection as you want return $collection;