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
Tax
_files
tax_classes_rollback.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
9
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
10
11
$taxRules
= [
12
'Test Rule'
,
13
'Test Rule Duplicate'
,
14
];
15
$taxClasses
= [
16
'ProductTaxClass1'
,
17
'ProductTaxClass2'
,
18
'ProductTaxClass3'
,
19
'CustomerTaxClass1'
,
20
'CustomerTaxClass2'
,
21
];
22
23
24
$taxRuleResource
=
$objectManager
->get(\
Magento
\Tax\Model\
ResourceModel
\Calculation\Rule::class);
25
foreach
(
$taxRules
as $taxRuleCode) {
26
$taxRule
=
$objectManager
->create(\
Magento
\Tax\Model\Calculation\Rule::class);
27
$taxRuleResource
->load(
$taxRule
, $taxRuleCode,
'code'
);
28
$taxRuleResource
->delete(
$taxRule
);
29
}
30
32
$resourceModel
=
$objectManager
->get(\
Magento
\Tax\Model\
ResourceModel
\TaxClass::class);
33
34
foreach
(
$taxClasses
as $taxClass) {
35
try
{
37
$taxClassEntity =
$objectManager
->create(\
Magento
\Tax\Model\ClassModel::class);
38
$resourceModel
->load($taxClassEntity, $taxClass,
'class_name'
);
39
$resourceModel
->delete($taxClassEntity);
40
}
catch
(\
Magento
\Framework\Exception\CouldNotDeleteException $couldNotDeleteException) {
41
// It's okay if the entity already wiped from the database
42
}
43
}
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
$taxRules
$taxRules
Definition:
tax_classes_rollback.php:11
$objectManager
$objectManager
Definition:
tax_classes_rollback.php:9
$taxRule
$taxRule
Definition:
tax_rule.php:35
$resourceModel
$resourceModel
Definition:
tax_classes_rollback.php:32
Magento
$taxClasses
$taxClasses
Definition:
tax_classes_rollback.php:15
$taxRuleResource
$taxRuleResource
Definition:
tax_classes_rollback.php:24
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125