Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. hgati created this gist Oct 25, 2023.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    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