Skip to content

Commit

Permalink
Merge pull request #6561 from magento-honey-badgers/PWA-1328
Browse files Browse the repository at this point in the history
[honey] PWA-1328: [PAP] Dynamic Blocks Implementation
  • Loading branch information
prabhuram93 authored Jan 28, 2021
2 parents 9c9a89e + ad3542a commit 2a4641b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

/** @var Magento\Framework\Registry $registry */
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Registry;
use Magento\SalesRule\Api\RuleRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;

$bootstrap = Bootstrap::getObjectManager();

/** @var Registry $registry */
$registry = $bootstrap->get(Registry::class);

/** @var RuleRepositoryInterface $ruleRepository */
$ruleRepository = $bootstrap->get(RuleRepositoryInterface::class);

/** @var Magento\SalesRule\Model\Rule $rule */
$rule = $registry->registry('cart_rule_40_percent_off');
if ($rule) {
$rule->delete();
$ruleId = $registry->registry('Magento/SalesRule/_files/cart_rule_40_percent_off');
if ($ruleId) {
try {
$ruleRepository->deleteById($ruleId);
$registry->unregister('Magento/SalesRule/_files/cart_rule_40_percent_off');
} catch (NoSuchEntityException $e) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

/** @var Magento\Framework\Registry $registry */
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Registry;
use Magento\SalesRule\Api\RuleRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;

$bootstrap = Bootstrap::getObjectManager();

/** @var Registry $registry */
$registry = $bootstrap->get(Registry::class);

/** @var RuleRepositoryInterface $ruleRepository */
$ruleRepository = $bootstrap->get(RuleRepositoryInterface::class);

/** @var Magento\SalesRule\Model\Rule $rule */
$rule = $registry->registry('cart_rule_50_percent_off');
if ($rule) {
$rule->delete();
$ruleId = $registry->registry('Magento/SalesRule/_files/cart_rule_50_percent_off');
if ($ruleId) {
try {
$ruleRepository->deleteById($ruleId);
$registry->unregister('Magento/SalesRule/_files/cart_rule_50_percent_off');
} catch (NoSuchEntityException $e) {
}
}

0 comments on commit 2a4641b

Please sign in to comment.