I want to display featured product of category at top of the product list with all filters, pagination and sorting.
For Example: I have an array of ID's that should show first in collection when category page open.
You can give the position of product which you have display top of the product list.
Go Adminpanel >> Catalog >> Categories.
After that edit that category that you want to show featured product on top. And click on "Product in Category"
Add position of that particular product which you want to show in top like below screen shot.
And check that product. And also one more thing if you don't get the product that run commands and check after that.
Thanks.
You can give the position of the productby using below way
$productIds = array(35731,35562, 35622, 35631);
$collection->getSelect()->order(new \Zend_Db_Expr('FIELD(e.entity_id, ' . implode(',', $productIds).') DESC'));
Try this
$productIds = array(35731,35562, 35622);
$collection->getSelect()->order(new \Zend_Db_Expr('FIELD(e.entity_id, ' . implode(',', $productIds).') DESC'));