I created 4 custom attributes for category. Now I want to remove it. I want to use object manager for delete attributes and its values.
See this image. Created attributes are display in this manner.
Now I created one file delete_attribute.php
in magento root folder.
<?php
ini_set('display_errors', 1);
//ini_set('memory_limit','-1');
error_reporting(E_ALL);
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$storeManager = $obj->get('\Magento\Store\Model\StoreManagerInterface');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State');
//$state->setAreaCode('frontend');
$state->setAreaCode('adminhtml');
// 165
// attribute_code1
// \Magento\Catalog\Model\Category
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('attribute_code1'); //Get Current Category
$PCategory = $objectManager->get('Magento\Catalog\Model\CategoryFactory')->create()->load(165);
echo $PCategory->getIsCollectionPageListing();
print_r($PCategory);
?>
Does anyone know how to delete these 4 attributes using object manager ?
Thanks in advance.