0

In Magento 2.4, I need to load multiple category data. How to load multiple category data by array of category ids?

2 Answers 2

0

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

enter image description here

THANKS.

0

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

1
  • Thanks for your code. I will check and let you know. Commented Jan 3, 2022 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.