Magento 2 Attribute Description Module

My first complete open source module for Magento 2 adds the ability for site owners and developers to add descriptions to product attributes. Magento gives you the ability to add a label to an attribute, like Color, Size, or Material, but it has no built-in way to describe what that attribute means. This can come in handy for certain product attributes which may be a little unique and need some explaining on what they mean. It would be great to use with tooltips or popups next to the attribute label on the frontend of your website to add more detail on a product attribute.

The module adds an extra field in the admin when editing a product attribute for you to fill in the attribute’s description. The description can also be translated into other languages for your different stores.

The module is geared towards developers because it requires a developer to write a bit of code to actually display the attribute description on the frontend of the website. As there are countless ways this attribute description could be used on the frontend of someone’s website, I figures it would be better to leave it to the developers to implement their own designs instead of adding something of my own which probably would be removed on every other site it was used on. If you want to get an attribute’s description its easy. Its in the Magento\Catalog\Model\ResourceModel\Eav\Attribute model and can be accessed by calling the function getStoreDescription like so:

$description = $attribute->getStoreDescription($storeId);

The module is on Packagist and on GitHub so it can be installed via Composer by adding the following to your composer.json:

"require": {
    "dmatthew/magento2-attribute-description": "*"
}

And that’s it! Now you can add descriptions to your product attributes to showcase on your site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s