cancel
Showing results for 
Search instead for 
Did you mean: 

Create entity type programmatically

Create entity type programmatically

I used these code to create attribute (sample only)

 

use \Magento\Eav\Api\AttributeRepositoryInterface $attributeType,
use \Magento\Eav\Api\Data\AttributeInterface $attributeInterface

assuming ctor assigned with above obj

$this->attributeInterface
->setAttributeId(2)
->setAttributeCode('test_ignore')
->setFrontendInput('test_ignore')
->setEntityTypeId(2)
->setIsRequired(1)

->setIsUserDefined(1)
->setDefaultFrontendLabel('test conf');
$this->attributeType->save($this->attributeInterface);

 

This code creates test data in "eav_attribute" table. I want to create a type before this and set it in setAttributeId(). Which API should I use? My magento version is 2.2.2

 

I could able to the list the types in admin component UI with class

\Magento\Eav\Model\ResourceModel\Entity\Type\Collection