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
Swatches
_files
products_with_layered_navigation_swatch_rollback.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
10
$registry
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(\
Magento
\Framework\Registry::class);
11
12
$registry
->unregister(
'isSecureArea'
);
13
$registry
->register(
'isSecureArea'
,
true
);
14
16
$productRepository
=
$objectManager
->create(\
Magento
\Catalog\Api\ProductRepositoryInterface::class);
17
18
foreach
([
'simple1'
,
'simple2'
,
'simple3'
] as $sku) {
19
try
{
20
$product
=
$productRepository
->get($sku,
false
,
null
,
true
);
21
$productRepository
->delete(
$product
);
22
}
catch
(\
Magento
\Framework\Exception\NoSuchEntityException $exception) {
23
//Product already removed
24
}
25
}
26
27
$productCollection
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()
28
->get(\
Magento
\Catalog\Model\
ResourceModel
\Product\Collection::class);
29
foreach
(
$productCollection
as
$product
) {
30
$product
->delete();
31
}
32
34
$category
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(\
Magento
\Catalog\Model\Category::class);
35
$category
->load(333);
36
if
(
$category
->getId()) {
37
$category
->delete();
38
}
39
41
$attribute
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()
42
->create(\
Magento
\Catalog\Model\
ResourceModel
\Eav\Attribute::class);
43
44
$attribute
->loadByCode(4,
'color_swatch'
);
45
46
if
(
$attribute
->getId()) {
47
$attribute
->delete();
48
}
49
50
$registry
->unregister(
'isSecureArea'
);
51
$registry
->register(
'isSecureArea'
,
false
);
$registry
$registry
Definition:
products_with_layered_navigation_swatch_rollback.php:10
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$productRepository
$productRepository
Definition:
products_with_layered_navigation_swatch_rollback.php:16
$category
$category
Definition:
products_with_layered_navigation_swatch_rollback.php:34
$productCollection
foreach(['simple1', 'simple2', 'simple3'] as $sku) $productCollection
Definition:
products_with_layered_navigation_swatch_rollback.php:27
Magento
$attribute
$attribute
Definition:
products_with_layered_navigation_swatch_rollback.php:41
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
$objectManager
$objectManager
Definition:
products_with_layered_navigation_swatch_rollback.php:8
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125