From 31bca48cacda1297bef910d5fb672753657f8666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kobierzy=C5=84ski?= Date: Thu, 5 Jun 2025 10:37:21 +0200 Subject: [PATCH] [ISSUE#153] Order states mixed with order statuses bugfix --- Model/Config.php | 6 +++--- .../{OrderPendingStates.php => OrderPendingStatuses.php} | 2 +- Model/Customer/CustomerChecker.php | 2 +- Model/Order/OrderChecker.php | 2 +- Model/Order/SourceProvider/GuestFilterModifier.php | 2 +- etc/adminhtml/system/erasure.xml | 8 ++++---- etc/config.xml | 2 +- i18n/bg_BG.csv | 2 +- i18n/da_DK.csv | 2 +- i18n/de_DE.csv | 2 +- i18n/en_US.csv | 2 +- i18n/fr_FR.csv | 2 +- i18n/it_IT.csv | 2 +- i18n/nl_NL.csv | 2 +- i18n/pl_PL.csv | 2 +- i18n/th_TH.csv | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) rename Model/Config/Source/{OrderPendingStates.php => OrderPendingStatuses.php} (91%) diff --git a/Model/Config.php b/Model/Config.php index e8471aaa..3a5fa91e 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -18,7 +18,7 @@ final class Config */ public const CONFIG_PATH_GENERAL_ENABLED = 'gdpr/general/enabled'; public const CONFIG_PATH_ERASURE_ENABLED = 'gdpr/erasure/enabled'; - public const CONFIG_PATH_ERASURE_ALLOWED_STATES = 'gdpr/erasure/allowed_states'; + public const CONFIG_PATH_ERASURE_ALLOWED_STATUSES = 'gdpr/erasure/allowed_statuses'; public const CONFIG_PATH_EXPORT_ENABLED = 'gdpr/export/enabled'; private ScopeConfigInterface $scopeConfig; @@ -48,10 +48,10 @@ public function isErasureEnabled(): bool /** * @return string[] */ - public function getAllowedStatesToErase(): array + public function getAllowedStatusesToErase(): array { return explode(',', (string) $this->scopeConfig->getValue( - self::CONFIG_PATH_ERASURE_ALLOWED_STATES, + self::CONFIG_PATH_ERASURE_ALLOWED_STATUSES, ScopeInterface::SCOPE_STORE )); } diff --git a/Model/Config/Source/OrderPendingStates.php b/Model/Config/Source/OrderPendingStatuses.php similarity index 91% rename from Model/Config/Source/OrderPendingStates.php rename to Model/Config/Source/OrderPendingStatuses.php index 00bc834e..cf4d1c7a 100644 --- a/Model/Config/Source/OrderPendingStates.php +++ b/Model/Config/Source/OrderPendingStatuses.php @@ -10,7 +10,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; -final class OrderPendingStates implements OptionSourceInterface +final class OrderPendingStatuses implements OptionSourceInterface { private CollectionFactory $collectionFactory; diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index b2894c75..92741b5a 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -40,7 +40,7 @@ public function __construct( public function canErase(int $customerId): bool { if (!isset($this->cache[$customerId])) { - $this->criteriaBuilder->addFilter(OrderInterface::STATE, $this->config->getAllowedStatesToErase(), 'nin'); + $this->criteriaBuilder->addFilter(OrderInterface::STATUS, $this->config->getAllowedStatusesToErase(), 'nin'); $this->criteriaBuilder->addFilter(OrderInterface::CUSTOMER_ID, $customerId); $orderList = $this->orderRepository->getList($this->criteriaBuilder->create()); diff --git a/Model/Order/OrderChecker.php b/Model/Order/OrderChecker.php index f021bae6..db4226d1 100644 --- a/Model/Order/OrderChecker.php +++ b/Model/Order/OrderChecker.php @@ -30,6 +30,6 @@ public function canErase(int $orderId): bool { $order = $this->orderRepository->get($orderId); - return in_array($order->getState(), $this->config->getAllowedStatesToErase(), true); + return in_array($order->getStatus(), $this->config->getAllowedStatusesToErase(), true); } } diff --git a/Model/Order/SourceProvider/GuestFilterModifier.php b/Model/Order/SourceProvider/GuestFilterModifier.php index 43ddbe75..7a1a6e75 100644 --- a/Model/Order/SourceProvider/GuestFilterModifier.php +++ b/Model/Order/SourceProvider/GuestFilterModifier.php @@ -31,6 +31,6 @@ public function apply(Collection $collection, Filter $filter): void { $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, ['null' => true]); $collection->addFieldToFilter(OrderInterface::CUSTOMER_IS_GUEST, ['eq' => 1]); - $collection->addFieldToFilter(OrderInterface::STATE, ['in' => $this->config->getAllowedStatesToErase()]); + $collection->addFieldToFilter(OrderInterface::STATUS, ['in' => $this->config->getAllowedStatusesToErase()]); } } diff --git a/etc/adminhtml/system/erasure.xml b/etc/adminhtml/system/erasure.xml index e586a386..0135e7a4 100644 --- a/etc/adminhtml/system/erasure.xml +++ b/etc/adminhtml/system/erasure.xml @@ -68,14 +68,14 @@ gdpr/erasure/sales_max_age - - - Opengento\Gdpr\Model\Config\Source\OrderPendingStates + + + Opengento\Gdpr\Model\Config\Source\OrderPendingStatuses 1 0 - gdpr/erasure/allowed_states + gdpr/erasure/allowed_statuses diff --git a/etc/config.xml b/etc/config.xml index b03705ce..829845e5 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -126,7 +126,7 @@ 1095 0 1 * * * 3650 - canceled,closed,complete + canceled,closed,complete 1