Skip to content

[ISSUE#153] Order states mixed with order statuses bugfix #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Model/Customer/CustomerChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion Model/Order/OrderChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion Model/Order/SourceProvider/GuestFilterModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
}
}
8 changes: 4 additions & 4 deletions etc/adminhtml/system/erasure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
</depends>
<config_path>gdpr/erasure/sales_max_age</config_path>
</field>
<field id="allowed_states" type="multiselect" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="80" canRestore="1">
<label>Allowed Order States to Erase</label>
<source_model>Opengento\Gdpr\Model\Config\Source\OrderPendingStates</source_model>
<field id="allowed_statuses" type="multiselect" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="80" canRestore="1">
<label>Allowed Order Statuses to Erase</label>
<source_model>Opengento\Gdpr\Model\Config\Source\OrderPendingStatuses</source_model>
<depends>
<field id="opengento_gdpr_erasure/erasure/enabled">1</field>
</depends>
<can_be_empty>0</can_be_empty>
<config_path>gdpr/erasure/allowed_states</config_path>
<config_path>gdpr/erasure/allowed_statuses</config_path>
</field>
<field id="customer_components_processors" type="text" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="90" canRestore="1">
<label>Customer Component Erasure Strategy</label>
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<entity_max_age>1095</entity_max_age>
<entity_max_age_schedule>0 1 * * *</entity_max_age_schedule>
<sales_max_age>3650</sales_max_age>
<allowed_states>canceled,closed,complete</allowed_states>
<allowed_statuses>canceled,closed,complete</allowed_statuses>
<remove_customer>1</remove_customer>
<customer_components_processors>
<![CDATA[{
Expand Down
2 changes: 1 addition & 1 deletion i18n/bg_BG.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"The time is in days.","The time is in days."
"Erase Old Entities Cron Schedule","Erase Old Entities Cron Schedule"
"Sales Information Lifetime","Sales Information Lifetime"
"Allowed Order States to Erase","Allowed Order States to Erase"
"Allowed Order Statuses to Erase","Allowed Order Statuses to Erase"
"Customer Component Erasure Strategy","Customer Component Erasure Strategy"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Defines the components erasure strategy with the component/erase processor mapper for the customers."
"Guest Component Erasure Strategy","Guest Component Erasure Strategy"
Expand Down
2 changes: 1 addition & 1 deletion i18n/da_DK.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"The time is in days.","Tiden er i dage."
"Erase Old Entities Cron Schedule","Slet gamle gnheder cron tidsplan"
"Sales Information Lifetime","Salgsinformation Levetid"
"Allowed Order States to Erase","Tilladte Ordretilstande til Sletning"
"Allowed Order Statuses to Erase","Tilladte Ordretilstande til Sletning"
"Customer Component Erasure Strategy","Kunde Komponent Slette Strategi"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Definerer komponentens slettestrategi med komponent/slette processor for kunderne."
"Guest Component Erasure Strategy","Gæst Komponent Slette Strategi"
Expand Down
2 changes: 1 addition & 1 deletion i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"The time is in days.","Die Zeit wird in Tagen angegeben."
"Erase Old Entities Cron Schedule","Alte Entitäten löschen Cron-Zeitplan"
"Sales Information Lifetime","Lebensdauer der Verkaufsinformationen"
"Allowed Order States to Erase","Erlaubte Bestellstatus zu löschen"
"Allowed Order Statuses to Erase","Erlaubte Bestellstatus zu löschen"
"Customer Component Erasure Strategy","Strategie zum Löschen von Kundenkomponenten"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Definiert die Komponentenlöschstrategie mit dem Komponenten-/Löschprozessor-Mapper für die Kunden."
"Guest Component Erasure Strategy","Löschstrategie für die Gast-Komponente"
Expand Down
2 changes: 1 addition & 1 deletion i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Erasure,Erasure
"The time is in days.","The time is in days."
"Erase Old Entities Cron Schedule","Erase Old Entities Cron Schedule"
"Sales Information Lifetime","Sales Information Lifetime"
"Allowed Order States to Erase","Allowed Order States to Erase"
"Allowed Order Statuses to Erase","Allowed Order Statuses to Erase"
"Customer Component Erasure Strategy","Customer Component Erasure Strategy"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Defines the components erasure strategy with the component/erase processor mapper for the customers."
"Guest Component Erasure Strategy","Guest Component Erasure Strategy"
Expand Down
2 changes: 1 addition & 1 deletion i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"The time is in days.","La durée est en jours."
"Erase Old Entities Cron Schedule","Planification du CRON pour l'effacement des vielles entités"
"Sales Information Lifetime","Durée de vie des information de ventes"
"Allowed Order States to Erase","État de commande autorisé pour le droit à l'oubli"
"Allowed Order Statuses to Erase","État de commande autorisé pour le droit à l'oubli"
"Customer Component Erasure Strategy","Stratégie d'effacement des entités pour les clients connectés"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Défini la stratégie d'effacement des composants à partir d'un mappage composant/processeur d'oubli pour les clients connectés."
"Guest Component Erasure Strategy","Stratégie d'effacement pour les invités"
Expand Down
2 changes: 1 addition & 1 deletion i18n/it_IT.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"The time is in days.","Il tempo è in giorni."
"Erase Old Entities Cron Schedule","Cron Schedule eliminazione vecchie entities"
"Sales Information Lifetime","Durata informazioni vendite"
"Allowed Order States to Erase","Stati Ordini permessi per l'eliminazione"
"Allowed Order Statuses to Erase","Stati Ordini permessi per l'eliminazione"
"Customer Component Erasure Strategy","Strategia eliminazione Componenti Clienti"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Definisci la strategia di eliminazione dei componenti per i clienti."
"Guest Component Erasure Strategy","Strategia eliminazione componenti guest"
Expand Down
2 changes: 1 addition & 1 deletion i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"The time is in days.","De tijd is in dagen."
"Erase Old Entities Cron Schedule","Verwijderen Van Oude Entiteiten (Geplande Taken)"
"Sales Information Lifetime","Leeftijd van informatie over verkopen"
"Allowed Order States to Erase","Toegestane statussen van bestelling om te verwijderen"
"Allowed Order Statuses to Erase","Toegestane statussen van bestelling om te verwijderen"
"Customer Component Erasure Strategy","Klant Component Verwijder Strategie"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Definieert de verwijder strategie van het component/verwijder processor koppeling voor de klanten"
"Guest Component Erasure Strategy","Gast Component Verwijder Strategie"
Expand Down
2 changes: 1 addition & 1 deletion i18n/pl_PL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"The time is in days.","Czas w dniach."
"Erase Old Entities Cron Schedule","Harmonogram CRON usuwania starych obiektów"
"Sales Information Lifetime","Czas istnienia informacji sprzedażowch"
"Allowed Order States to Erase","Statusy Zamówień możliwe do usunięcia"
"Allowed Order Statuses to Erase","Statusy Zamówień możliwe do usunięcia"
"Customer Component Erasure Strategy","Strategia czyszczenia komponentu Klienta"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","Defines the components erasure strategy with the component/erase processor mapper for the customers."
"Guest Component Erasure Strategy","Strategia czyszczenia komponentu Gościa"
Expand Down
2 changes: 1 addition & 1 deletion i18n/th_TH.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"The time is in days.","เวลาเป็นวัน"
"Erase Old Entities Cron Schedule","ลบกำหนดการ Cron ของข้อมุลเก่า"
"Sales Information Lifetime","อายุข้อมูลการขาย"
"Allowed Order States to Erase","อนุญาตให้ลบข้อมูลสั่งซื้อ"
"Allowed Order Statuses to Erase","อนุญาตให้ลบข้อมูลสั่งซื้อ"
"Customer Component Erasure Strategy","คอมโพเน้นท์เงื่อนไขการลบข้อมูลลูกค้า"
"Defines the components erasure strategy with the component/erase processor mapper for the customers.","กำหนดกลยุทธ์การลบด้วยคอมโพเนนท์/ตัวประมวลผลข้อมูลสำหรับลูกค้า"
"Guest Component Erasure Strategy","คอมโพเน้นท์เงื่อนไขการลบข้อมูล Guest"
Expand Down