Magento 2: Load a Product Collection by IDs
Load a Magento 2 product collection by ID in a custom template, filtered to the products and attributes you need — with working code.
I got product collection in my custom template using following code
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
foreach ($productCollection as $product) {
$product_id=$product['entity_id'];
echo $_product->getName();
}?>
Further reading: Adobe Commerce PHP developer guide. Need a hand? Our web development team can help.
