Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Catalog
_files
attribute_set_with_image_attribute.php
Go to the documentation of this file.
1
<?php
8
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
9
11
$attributeSet
=
$objectManager
->create(\
Magento
\Eav\Model\Entity\Attribute\Set::class);
12
13
$entityType
=
$objectManager
->create(\
Magento
\Eav\Model\Entity\Type::class)->loadByCode(
'catalog_product'
);
14
$defaultSetId
=
$objectManager
->create(\
Magento
\Catalog\Model\Product::class)->getDefaultAttributeSetid();
15
16
$data
= [
17
'attribute_set_name'
=>
'attribute_set_with_media_attribute'
,
18
'entity_type_id'
=>
$entityType
->getId(),
19
'sort_order'
=> 200,
20
];
21
22
$attributeSet
->setData(
$data
);
23
$attributeSet
->validate();
24
$attributeSet
->save();
25
$attributeSet
->initFromSkeleton(
$defaultSetId
);
26
$attributeSet
->save();
27
28
$attributeData
= [
29
'entity_type_id'
=>
$entityType
->getId(),
30
'attribute_code'
=>
'funny_image'
,
31
'frontend_input'
=>
'media_image'
,
32
'frontend_label'
=>
'Funny image'
,
33
'backend_type'
=>
'varchar'
,
34
'is_required'
=> 0,
35
'is_user_defined'
=> 1,
36
'attribute_set_id'
=>
$attributeSet
->getId(),
37
'attribute_group_id'
=>
$attributeSet
->getDefaultGroupId(),
38
];
39
41
$attribute
=
$objectManager
->create(\
Magento
\Catalog\Model\Entity\Attribute::class);
42
$attribute
->setData(
$attributeData
);
43
$attribute
->save();
$defaultSetId
$defaultSetId
Definition:
attribute_set_with_image_attribute.php:14
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
$entityType
$entityType
Definition:
attribute_set_with_image_attribute.php:13
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento
$attributeSet
$attributeSet
Definition:
attribute_set_with_image_attribute.php:11
$objectManager
$objectManager
Definition:
attribute_set_with_image_attribute.php:8
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125
$attributeData
$attributeData
Definition:
attribute_set_with_image_attribute.php:28