How to Active Magento 2 Category Programmatically

How can I active a Magento 2 category programmatically based on given category ID

After load Magento 2 category object, you can use setIsActive method to active or inactive the category.

$catid = 1;
$storeid = 1;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$categoryRepository = $objectManager->get(‘MagentoCatalogModelCategoryRepository’);
$category = $categoryRepository->get($catid , $storeid);
$category->setIsActive(true);
$categoryRepository->save($category);

Leave a Reply

avatar
  Subscribe  
Notify of