Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgati/72cfd2ee948e4dba9e15e96b2084c056 to your computer and use it in GitHub Desktop.
Save hgati/72cfd2ee948e4dba9e15e96b2084c056 to your computer and use it in GitHub Desktop.
Magento2 DeleteOrder patch #3
From 28b02fb73a5159b1145033cf87927ab5a065917f Mon Sep 17 00:00:00 2001
From: Dennis <cobays@gmail.com>
Date: Wed, 25 Oct 2023 13:53:54 +0900
Subject: [PATCH 3/3] Fixed an error : delete operation is forbidden
---
Console/Command/DeleteOrdersCommand.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Console/Command/DeleteOrdersCommand.php b/Console/Command/DeleteOrdersCommand.php
index e2689fa..793bfd9 100644
--- a/Console/Command/DeleteOrdersCommand.php
+++ b/Console/Command/DeleteOrdersCommand.php
@@ -35,6 +35,11 @@ class DeleteOrdersCommand extends Command
*/
protected $helper;
+ /**
+ * @var \Magento\Framework\Registry
+ */
+ protected $registry;
+
/**
* Init constructor
*
@@ -57,6 +62,7 @@ class DeleteOrdersCommand extends Command
$this->orderFactory = $orderFactory;
$this->order = $order;
$this->helper = $helper;
+ $this->registry = $registry;
parent::__construct();
}
@@ -91,6 +97,7 @@ class DeleteOrdersCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
$exitCode = 0;
+ $this->registry->register('isSecureArea', true); // This action (true) must be performed in order to enable the delete action.
try {
--
2.34.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment