I want to show the specific products from array via list.phtml
with pagination.
I referred https://github.com/BssGroup/HelloWorld and wrote the below code in block and controller.
$collection->addAttributeToFilter('entity_id', ['in' => $ids]);
But it gives all products when visiting http://localhost/helloworld/index/index page.
What is the best possible way to achieve this in Magento 2?
I am using Magento version 2.4.3-p1.