Skip to main content
added 87 characters in body
Source Link
Rajesh Hothi
  • 677
  • 1
  • 4
  • 16

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

enter image description here

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

enter image description here

edited body
Source Link
Rajesh Hothi
  • 677
  • 1
  • 4
  • 16

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 3;2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 3;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

added 77 characters in body
Source Link
Rajesh Hothi
  • 677
  • 1
  • 4
  • 16

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;3;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
       ->addIdFilter($parentCategory->getChildren());
              ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 2;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
                      ->addIdFilter($parentCategory->getChildren());
            
        print_r($collection->getData());

I Hope It's Will Helpful.

Please try below collection.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentCategoryId = 3;
$parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId);


    $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->addAttributeToSelect('*')
                      ->setOrder('position', 'ASC')
              ->addFieldToFilter('is_active',array("in"=>array('0', '1')))
                     ->addAttributeToFilter('parent_id',['eq'=>$parentCategoryId]);

        print_r($collection->getData());

I Hope It's Will Helpful.

added 236 characters in body
Source Link
Rajesh Hothi
  • 677
  • 1
  • 4
  • 16
Loading
Source Link
Rajesh Hothi
  • 677
  • 1
  • 4
  • 16
Loading