In Magento 2.4, I need to load multiple category data. How to load multiple category data by array of category ids?
2 Answers
I have not clear you question but as per my assume.I have make to array of category ids. Just i have use object manager.
$categoryCollection = $object_Manager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory')->create();
$categoryCollection->addFieldToFilter('entity_id', [3, 4]);
foreach ($categoryCollection->getItems() as $category) {
/** @var \Magento\Catalog\Model\Category\Interceptor $category */
// get the category data
echo "<pre>";
var_dump($category->getData());
}
die("Helllo");
And see both category data
THANKS.
You should do something like :
$categoryCollection = $object_Manager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory')->create();
$categoryCollection->addFieldToFilter('entity_id', ['in' => [3, 4]]);
Hope it helps