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
unique_input_attribute.php
Go to the documentation of this file.
1
<?php
10
$entityType
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
11
\
Magento
\Eav\Model\Entity\Type::class
12
);
13
$entityType
->loadByCode(
'catalog_product'
);
14
$defaultSetId
=
$entityType
->getDefaultAttributeSetId();
16
$defaultSet
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
17
\
Magento
\Eav\Model\Entity\Attribute\Set::class
18
);
19
$defaultSet
->load(
$defaultSetId
);
20
$defaultGroupId
=
$defaultSet
->getDefaultGroupId();
21
23
$attribute
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
24
\
Magento
\Catalog\Model\
ResourceModel
\Eav\Attribute::class
25
);
26
$attribute
->setAttributeCode(
27
'unique_input_attribute'
28
)->setEntityTypeId(
29
$entityType
->getEntityTypeId()
30
)->setAttributeGroupId(
31
$defaultGroupId
32
)->setAttributeSetId(
33
$defaultSetId
34
)->setFrontendInput(
35
'text'
36
)->setFrontendLabel(
37
'Unique Input Attribute'
38
)->setBackendType(
39
'varchar'
40
)->setIsUserDefined(
41
1
42
)->setIsUnique(
43
1
44
)->save();
$defaultSet
$defaultSet
Definition:
unique_input_attribute.php:16
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$defaultSetId
$defaultSetId
Definition:
unique_input_attribute.php:14
$attribute
$attribute
Definition:
unique_input_attribute.php:23
$entityType
$entityType
Definition:
unique_input_attribute.php:10
Magento
$defaultGroupId
$defaultGroupId
Definition:
unique_input_attribute.php:20
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125