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
Elasticsearch
_files
select_attribute.php
Go to the documentation of this file.
1
<?php
6
use
Magento\TestFramework\Helper\Bootstrap
;
7
8
$objectManager
= Bootstrap::getObjectManager();
9
11
$installer
=
$objectManager
->create(\
Magento
\Catalog\Setup\CategorySetup::class);
12
14
$selectAttribute
=
$objectManager
->create(\
Magento
\Catalog\Model\
ResourceModel
\Eav\Attribute::class);
15
$selectAttribute
->setData(
16
[
17
'attribute_code'
=>
'select_attribute'
,
18
'entity_type_id'
=>
$installer
->getEntityTypeId(
'catalog_product'
),
19
'is_global'
=> 1,
20
'is_user_defined'
=> 1,
21
'frontend_input'
=>
'select'
,
22
'is_unique'
=> 0,
23
'is_required'
=> 0,
24
'is_searchable'
=> 1,
25
'is_visible_in_advanced_search'
=> 0,
26
'is_comparable'
=> 0,
27
'is_filterable'
=> 1,
28
'is_filterable_in_search'
=> 0,
29
'is_used_for_promo_rules'
=> 0,
30
'is_html_allowed_on_front'
=> 1,
31
'is_visible_on_front'
=> 0,
32
'used_in_product_listing'
=> 0,
33
'used_for_sort_by'
=> 0,
34
'frontend_label'
=> [
'Select Attribute'
],
35
'backend_type'
=>
'varchar'
,
36
'backend_model'
=> \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
37
'option'
=> [
38
'value'
=> [
39
'chair'
=> [
'Chair'
],
40
'table'
=> [
'Table'
],
41
],
42
'order'
=> [
43
'chair'
=> 1,
44
'table'
=> 2,
45
],
46
],
47
]
48
);
49
$selectAttribute
->save();
50
51
$installer
->addAttributeToGroup(
52
'catalog_product'
,
53
'Default'
,
54
'General'
,
55
$selectAttribute
->getId()
56
);
57
59
$selectOptions
=
$objectManager
->create(
60
\
Magento
\Eav\Model\
ResourceModel
\Entity\Attribute\Option\Collection::class
61
);
62
$selectOptions
->setAttributeFilter(
$selectAttribute
->getId());
63
$selectOptionsIds
=
$selectOptions
->getAllIds();
$installer
$installer
Definition:
select_attribute.php:11
$selectOptionsIds
$selectOptionsIds
Definition:
select_attribute.php:63
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
Magento
$selectOptions
$selectOptions
Definition:
select_attribute.php:59
$objectManager
$objectManager
Definition:
select_attribute.php:8
$selectAttribute
$selectAttribute
Definition:
select_attribute.php:14