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
products_for_index_rollback.php
Go to the documentation of this file.
1
<?php
6
use
Magento\Catalog\Api\Data\ProductInterface
;
7
use
Magento\Catalog\Api\ProductRepositoryInterface
;
8
use
Magento\Framework\Api\SearchCriteriaBuilder
;
9
use
Magento\Framework\Registry
;
10
use
Magento\TestFramework\Helper\Bootstrap
;
11
12
Bootstrap::getInstance()->
getInstance
()->reinitialize();
13
15
$registry
= Bootstrap::getObjectManager()->get(Registry::class);
16
17
$registry
->unregister(
'isSecureArea'
);
18
$registry
->register(
'isSecureArea'
,
true
);
19
21
$productRepository
= Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
22
23
$productSkus
= [
24
'index_enabled'
,
25
'index_disabled'
,
26
'index_visible_search'
,
27
'index_visible_category'
,
28
'index_visible_both'
,
29
'index_not_visible'
30
];
32
$searchCriteriaBuilder
= Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
33
$searchCriteriaBuilder
->addFilter(ProductInterface::SKU,
$productSkus
,
'in'
);
34
$result
=
$productRepository
->getList(
$searchCriteriaBuilder
->create());
35
foreach
(
$result
->getItems() as
$product
) {
36
$productRepository
->delete(
$product
);
37
}
38
39
$registry
->unregister(
'isSecureArea'
);
40
$registry
->register(
'isSecureArea'
,
false
);
$searchCriteriaBuilder
$searchCriteriaBuilder
Definition:
products_for_index_rollback.php:32
Magento\Framework\Api\SearchCriteriaBuilder
Definition:
SearchCriteriaBuilder.php:14
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
Magento\TestFramework\Helper\Bootstrap\getInstance
static getInstance()
Definition:
Bootstrap.php:49
$productRepository
$productRepository
Definition:
products_for_index_rollback.php:21
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
$productSkus
$productSkus
Definition:
products_for_index_rollback.php:23
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
$registry
$registry
Definition:
products_for_index_rollback.php:15
Magento\Framework\Registry
Definition:
Registry.php:18
$result
$result
Definition:
products_for_index_rollback.php:34
Magento\Catalog\Api\Data\ProductInterface
Definition:
ProductInterface.php:14