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
CatalogSearch
_files
search_attributes.php
Go to the documentation of this file.
1
<?php
7
/* Create attribute */
9
$installer
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
10
\
Magento
\Catalog\Setup\CategorySetup::class
11
);
12
13
$attributesData
= [
14
[
15
'attribute_code'
=>
'test_quick_search'
,
16
'is_filterable_in_search'
=> 1,
17
],
18
[
19
'attribute_code'
=>
'test_catalog_view'
,
20
'is_filterable'
=> 1,
21
]
22
];
23
24
foreach
(
$attributesData
as
$data
) {
25
27
$attribute
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
28
\
Magento
\Catalog\Model\
ResourceModel
\Eav\Attribute::class
29
);
30
$attributeData
= array_merge(
31
[
32
'attribute_code'
=>
''
,
33
'entity_type_id'
=>
$installer
->getEntityTypeId(
'catalog_product'
),
34
'is_global'
=> 1,
35
'is_user_defined'
=> 1,
36
'frontend_input'
=>
'select'
,
37
'is_unique'
=> 0,
38
'is_required'
=> 1,
39
'is_searchable'
=> 0,
40
'is_visible_in_advanced_search'
=> 0,
41
'is_comparable'
=> 0,
42
'is_filterable'
=> 0,
43
'is_filterable_in_search'
=> 0,
44
'is_used_for_promo_rules'
=> 0,
45
'is_html_allowed_on_front'
=> 1,
46
'is_visible_on_front'
=> 0,
47
'used_in_product_listing'
=> 0,
48
'used_for_sort_by'
=> 0,
49
'frontend_label'
=> [
'Test Configurable'
],
50
'backend_type'
=>
'int'
,
51
'option'
=> [
52
'value'
=> [
'option_0'
=> [
'Option 1'
],
'option_1'
=> [
'Option 2'
]],
53
'order'
=> [
'option_0'
=> 1,
'option_1'
=> 2],
54
],
55
],
56
$data
57
);
58
$attribute
->setData(
$attributeData
);
59
$attribute
->save();
60
/* Assign attribute to attribute set */
61
$installer
->addAttributeToGroup(
'catalog_product'
,
'Default'
,
'General'
,
$attribute
->getId());
62
}
63
65
$eavConfig
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(\
Magento
\Eav\Model\Config::class);
66
$eavConfig
->clear();
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
$installer
$installer
Definition:
search_attributes.php:9
$eavConfig
$eavConfig
Definition:
search_attributes.php:65
$attributesData
$attributesData
Definition:
search_attributes.php:13
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125
$attributeData
$attributeData
Definition:
attribute_set_with_image_attribute.php:28