Skip to content

Instantly share code, notes, and snippets.

@codekipple
Last active May 10, 2017 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codekipple/4f4c2eef97623c1360236e13588f36b5 to your computer and use it in GitHub Desktop.
Save codekipple/4f4c2eef97623c1360236e13588f36b5 to your computer and use it in GitHub Desktop.
Mangento 2, adding a new image role
<?php
// the group name has to be 'Image Management' rather than 'Image' as it has to match the 'attribute_group_code' rather than the 'attribute_group_name' in the 'eav_attribute_group' table.
// See convertToAttributeGroupCode() in \Magento\Eav\Setup\EavSetup
$this->eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'test_image_role',
[
'group' => 'Image Management',
'type' => 'varchar',
'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image',
'label' => 'Test image role',
'input' => 'media_image',
'class' => '',
'source' => '',
'global' => 0,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => null,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment