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
Framework
Search
_files
filterable_attribute_rollback.php
Go to the documentation of this file.
1
<?php
6
/* Create attribute */
8
$installer
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
9
\
Magento
\Catalog\Setup\CategorySetup::class,
10
[
'resourceName'
=>
'catalog_setup'
]
11
);
13
$attribute
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
14
\
Magento
\Catalog\Model\
ResourceModel
\Eav\Attribute::class
15
);
16
$attribute
->loadByCode(\
Magento
\Catalog\Model\Product::ENTITY,
'select_attribute'
);
17
19
$selectOptions
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
20
\
Magento
\Eav\Model\
ResourceModel
\Entity\Attribute\Option\Collection::class
21
);
22
$registry
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(\
Magento
\Framework\Registry::class);
23
24
$registry
->unregister(
'isSecureArea'
);
25
$registry
->register(
'isSecureArea'
,
true
);
26
27
$selectOptions
->setAttributeFilter(
$attribute
->getId());
28
/* Delete simple products per each select(dropdown) option */
29
foreach
(
$selectOptions
as
$option
) {
31
$product
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
32
\
Magento
\Catalog\Model\Product::class
33
);
34
$product
=
$product
->loadByAttribute(
'sku'
,
'simple_product_'
.
$option
->getId());
35
if
(
$product
->getId()) {
36
$product
->delete();
37
}
38
}
39
if
(
$attribute
->getId()) {
40
$attribute
->delete();
41
}
42
43
$attribute
->loadByCode(
$installer
->getEntityTypeId(
'catalog_product'
),
'multiselect_attribute'
);
44
if
(
$attribute
->getId()) {
45
$attribute
->delete();
46
}
47
48
$registry
->unregister(
'isSecureArea'
);
49
$registry
->register(
'isSecureArea'
,
false
);
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$installer
$installer
Definition:
filterable_attribute_rollback.php:8
$attribute
$attribute
Definition:
filterable_attribute_rollback.php:13
$registry
$registry
Definition:
filterable_attribute_rollback.php:22
Magento
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
$selectOptions
$selectOptions
Definition:
filterable_attribute_rollback.php:19
$option
$option
Definition:
product_configurable_with_single_child.php:38
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125