pim-docs icon indicating copy to clipboard operation
pim-docs copied to clipboard

[Cookbook] Customizing and creating attributes

Open a2xchip opened this issue 9 years ago • 2 comments

I'm reporting feature request

According to @nidup answer on issue #267: cookbook section about customizing attribute types and creating new attribute types is very expected.

Let's discuss page basic structure :eyes:

a2xchip avatar Apr 18 '16 22:04 a2xchip

@pierallard @nidup @jjanvier @jmleroux @LeoBenoist @momoss @fitn What about example we may use for this section? I mean custom attribute we will explain about in cookbook section...

a2xchip avatar Apr 29 '16 20:04 a2xchip

Hi @a2xchip

Yes this cookbook is very expected for a very long time now, thank you for opening the discussion :tada: :tada:

It should be added in http://docs.akeneo.com/master/cookbook/catalog_structure/index.html and maybe requires to re-organize this chapter.

When creating a new attribute type you can re-use a lot of existing parts provided by another attribute types, for instance, for the UI display in the product edit form or the filter to be used in the product datagrid. If you need to create all the services, it's a big work, we handle this with Registry and tagged services, for instances, the tags 'pim_catalog.updater.setter', 'pim_catalog.updater.copier', 'pim_catalog.updater.adder', 'pim_catalog.updater.remover', 'pim_catalog.doctrine.query.filter', 'pim_catalog.doctrine.query.sorter', etc. In fact any feature that may depends on the attribute type provides a registry which allow you to register a tagged service providing the related service for your attribute type.

In 80% of cases, a new attribute type can be achieved by using the existing Reference Data attribute type, cf http://docs.akeneo.com/master/cookbook/catalog_structure/creating_a_reference_data.html

Reference data allows to use simple select or multi select to build a link between a product and a custom entity of your choice.

The 20% of remaining cases are in fact more complex cases, for instance, be able to "embed" a data in a product value, like price collection or metric, the product value contains the data, it's not a link to a data.

I think we should re-organize the http://docs.akeneo.com/master/cookbook/catalog_structure/index.html page to be more business use cases oriented.

For instance,

Use case 1, I need to create a manufacturer attribute to link a product to a manufacturer. The manufacturer entity is not as simple as standard options, I want to add a code, a label and a country. I can to this by creating a new Manufacturer entity and by using the reference data system. (this cookbook exists adding a color example which is very already very ok, no need to change it http://docs.akeneo.com/master/cookbook/catalog_structure/creating_a_reference_data.html)

Use case 2, (the missing one) Could be for instance, I need a "range" attribute type, defining a minimum and a maximum, the product value is belonging to the product value (like a metric). The business use case should be,

  • I'm a board game seller
  • I need to create an attribute "nb_players" using the attribute type "range"
  • The game "Zombicide" of the family "board_game" contains a value "from 2 to 6" for the attribute "nb_players"

To do so, I need a new entity, a new UI (slider?), a new grid filter, etc

nidup avatar Apr 30 '16 14:04 nidup