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
Model
Layer
Filter
_files
attribute_with_option_rollback.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
);
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,
'attribute_with_option'
);
17
18
/* Delete simple products per each option */
20
$options
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
21
\
Magento
\Eav\Model\
ResourceModel
\Entity\Attribute\Option\Collection::class
22
);
23
$registry
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(\
Magento
\Framework\Registry::class);
24
25
$registry
->unregister(
'isSecureArea'
);
26
$registry
->register(
'isSecureArea'
,
true
);
27
$options
->setAttributeFilter(
$attribute
->getId());
28
29
foreach
(
$options
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
40
if
(
$attribute
->getId()) {
41
$attribute
->delete();
42
}
43
44
$registry
->unregister(
'isSecureArea'
);
45
$registry
->register(
'isSecureArea'
,
false
);
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$attribute
$attribute
Definition:
attribute_with_option_rollback.php:13
$installer
$installer
Definition:
attribute_with_option_rollback.php:9
$options
$options
Definition:
attribute_with_option_rollback.php:20
Magento
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
$option
$option
Definition:
product_configurable_with_single_child.php:38
$registry
$registry
Definition:
attribute_with_option_rollback.php:23
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125