Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
attribute_set_with_image_attribute_rollback.php
Go to the documentation of this file.
1 <?php
9 
10 $entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product');
11 
12 // remove attribute
13 
15 $attributeCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
16 $attributeCollection->setFrontendInputTypeFilter('media_image');
17 $attributeCollection->setCodeFilter('funny_image');
18 $attributeCollection->setEntityTypeFilter($entityType->getId());
19 $attributeCollection->setPageSize(1);
20 $attributeCollection->load();
22 $attribute->delete();
23 
24 // remove attribute set
25 
28  \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class
29 );
30 $attributeSetCollection->addFilter('attribute_set_name', 'attribute_set_with_media_attribute');
31 $attributeSetCollection->addFilter('entity_type_id', $entityType->getId());
32 $attributeSetCollection->setOrder('attribute_set_id'); // descending is default value
33 $attributeSetCollection->setPageSize(1);
35 
38 $attributeSet->delete();