I recently had the issue that I needed to use the \Magento\Eav\Setup\EavSetup outside the setup-context. To be a bit more concrete, I wanted to import attribute-sets, attributes and attribute-options without using an install-script. My first idea was in magento2 you can easily inject the ‘EavSetup’ via constructor injection and then use it in your own class First try So I injected into my class which worked out well in the development-mode.
* SomeAttribute constructor.
* @param \Some\Own\AttributeContext $context
* @param \Magento\Eav\Setup\EavSetup $eavSetup
* @param string $entityTypeId
public function __construct(
$entityTypeId = Product::ENTITY
$this->eavSetup = $eavSetup;
$this->entityTypeId = $entityTypeId;
But using the same code with the production-mode a…