I was searching throughout net i have not found complete tutorial.
The case is I need complete configuration for newly added attribute (for product) and explantation of use of each one, adding it with use of sqlk script. If you have some notes somewhere about it, it would be extremely useful for me to can look at them.
Of course if I can find it somewhere in core, it will be ok, but so far I have not found complete sql script.
For now I have gathered:
$eavSetup->addAttribute(
Product::ENTITY,
'licensed_soft',
[
'type' => 'int',
'input' => 'select',
'frontend_class' => 'required-entry integer',
'label' => 'Licensed software',
'group' => 'License details',
'sort_order' => 10,
'backend' => '',
'frontend' => '',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'default' => 0,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => true,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
//'apply_to' => ''
]
);
Some of attributes I have to add are connected only with backend and some of them should be visible on front etc. Is it only visible_on_front
? Or comparable
or filterable
mean something on front? What is product listing?
If anyone knows frontend class to validate min length of provided content of input it would be also useful.
Thanks in advance!
Best Answer
like you I was not able to find any official documentation for this, that is unfortunate. Personally I was able to get some information from random tutorial examples like this one: https://www.atwix.com/magento/adding-attribute-programatically-magento2/
However an interesting thing is that by doing a search for the string "used_in_product_listing" on the vendor/magento folder turned me to the Magento\Catalog\Model\ResourceModel\Eav\Attribute which seems to contain the list of existing options for EAV attributes and other interesting information like the list of allowed input types:
This might not contain all the info you are looking for but at least it flashes the name of a few options you can use in your attribute definitions (without any help on what they actually do, but some of the names are pretty self explanatory)