Browsed by
Tag: EAV

Use EavSetup to Import Attributes

Use EavSetup to Import Attributes

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 *…

Read More Read More

Fixing issues after changing product attribute type from varchar to text

Fixing issues after changing product attribute type from varchar to text

In some cases there is a need to change the backend type of a catalog product attribute from varchar to text. The purpose of this change is to get more than 255 characters space for a string value. In this article I will cover the situation when problems occur after changing the backend type of an attribute. The Problem If the backend type of an attribute is changed, e.g. via install/upgrade script, Magento does not automatically copy and clean up old values….

Read More Read More

Thoughts about custom attributes and the way to manage them!

Thoughts about custom attributes and the way to manage them!

To add or update an EAV attribute in Magento, it is necessary to add setup scripts to your code base. If you don’t handle your custom attributes in setup scripts, you are not able to install your project from scratch, which could cause a lot of problems. For example, it makes it harder to run unit- and integration tests. So lets assume that we are working in a team with 4 developers and everybody has a different task. Each task…

Read More Read More