Skip to content

Product added to the Catalog collection does not display a price

I created a preference for the block MagentoCatalogBlockProductListProduct to add a specific product at the begining of the collection in getLoadedProductCollection(). Almost everything is well displayed except the price.

public function getLoadedProductCollection()
    {
        $originalCollection= parent::getLoadedProductCollection();
        $featuredProduct = $this->productFactory->create()->load(18); //test productId
        if ($this->_request->getFullActionName() !== 'catalogsearch_result_index' || !$featuredProduct) {
            return $originalCollection;
        }

        $newCollection = clone $originalCollection;
        $newCollection->removeAllItems();

        try {
            if($featuredProduct->getId()) {
                $newCollection->addItem($featuredProduct);
            }
            foreach ($originalCollection as $item) {
                if ($item->getId() != $featuredProduct->getId()) {
                    $newCollection->addItem($item);
                }
            }
        } catch (Exception) {}
        return $newCollection;
    }

I’m not sure why in list.phtml, $block->getProductPrice($_product) return an empty string only for this product. The rest of the catalog is working normally.