Read More
Read More
Menu Close

    How to create a New Attribute Type in Akeneo

    How to create a New Attribute Type in Akeneo
    Choose attribute type in Akeneo

    Introduction

    An attribute is a product’s characteristic. A product is usually composed of several attributes: an identification number, a name, a description, a price, a color… Depending on your Akeneo Edition version (Community or Enterprise), you can choose from 18 attribute types.

    A product family is the collection of attributes that will be the same for all products related to that family. After creating the attribute and attribute group we assign them to a product family., check our What is family? article.

    View Post

    You can easily create attribute groups to gather your attributes and ease their enrichment in the product form. Read the article to get more information about attribute groups: How to Create Attributes and Attributes Groups in Akeneo?

    let’s start with how to create a new attribute type in Akeneo

    Start your headless eCommerce
    now.
    Read More

    How to create a new attribute type in Akeneo

    1. The first thing we need is to declare a new service for the New Attribute Type (below attribute type name taken as ‘url_media’)

    Make sure that the file containing your declaration is correctly loaded by your bundle extension.

    parameters:
        acme_catalog.attribute_type.url_media.class: Acme\Bundle\AttributeTypeBundle\Component\AttributeType\UrlMediaType
        
    services:
        acme_catalog.attributetype.url_media:
            class: '%acme_catalog.attribute_type.url_media.class%'
            arguments:
                - 'text'
            tags:
                - { name: pim_catalog.attribute_type, alias: pim_catalog_url_media, entity: '%pim_catalog.entity.product.class% }

    2. Create a class of above register attribute type service

    <?php
    
    namespace  Acme\Bundle\AttributeTypeBundle\Component\AttributeType;
    
    use Akeneo\Pim\Structure\Component\AttributeType\AbstractAttributeType;
    
    class UrlMediaType extends AbstractAttributeType
    {
         /**
          * {@inheritdoc}
          */
         public function getName()
         {
             return 'pim_catalog_url_media';
         }
     }

    3. Add Attribute Type custom icon 

    a) Add the below configuration in ‘Acme/Bundle/AttributeTypeBundle/Resources/config/requirejs.yml’

    config:
        config:
            pim/form/common/attributes/create-button:
                attribute_icons:
                    pim_catalog_url_media: url_media

    b) Create less file in ‘Acme/Bundle/AttributeTypeBundle/Resources/public/less/index.less’ and add icon path as given below reference

    .AknButton-squareIcon--url_media {
        background-image: url("../bundles/attributetype/images/icon-url_media.svg");
    }

    4. Run the following command using the terminal at your PIM root directory.

    ( Note: Please note that neither the Apache user or the CLI should be the root user of the system. )

    php bin/console cache:clear --env=prod && php bin/console pim:installer:assets --symlink --clean --env=prod && yarn run webpack && php bin/console d:s:u --force

    Please explore our Akeneo Development Services and Quality Akeneo Extensions.

    For more Akeneo blogs click here

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top