File tree Expand file tree Collapse file tree 7 files changed +28
-4
lines changed Expand file tree Collapse file tree 7 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 13
13
*/
14
14
class CleanReservations
15
15
{
16
- const RESERVATIONS_CONFIG_KEY = 'allegro/order/reservations_enabled ' ;
16
+ const RESERVATIONS_CRON_CONFIG_KEY = 'allegro/order/reservations_cron_enabled ' ;
17
17
18
18
/** @var Logger */
19
19
private $ logger ;
@@ -41,7 +41,7 @@ public function __construct(
41
41
42
42
public function execute ()
43
43
{
44
- if ($ this ->scopeConfig ->getValue (self ::RESERVATIONS_CONFIG_KEY )) {
44
+ if ($ this ->scopeConfig ->getValue (self ::RESERVATIONS_CRON_CONFIG_KEY )) {
45
45
$ this ->logger ->addInfo ("Cronjob clean reservations is executed. " );
46
46
$ this ->allegroReservation ->cleanOldReservations ();
47
47
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class Configuration
16
16
const DESCRIPTION_ATTRIBUTE_CONFIG_PATH = 'allegro/offer_create/description_attribute ' ;
17
17
const STORE_ID_CONFIG_PATH = 'allegro/order/store ' ;
18
18
const RESERVATIONS_ENABLED_CONFIG_PATH = 'allegro/order/reservations_enabled ' ;
19
+ const RESERVATIONS_CRON_ENABLED_CONFIG_PATH = 'allegro/order/reservations_cron_enabled ' ;
19
20
const LAST_EVENT_ID_FLAG_NAME = 'allegro_order_last_event_id ' ;
20
21
const LAST_USER_ID_FLAG_NAME = 'allegro_credentials_last_user_id ' ;
21
22
const INITIALIZATION_TIME_FLAG_NAME = 'allegro_initialization_time ' ;
@@ -87,6 +88,18 @@ public function areReservationsEnabled(
87
88
return $ this ->scopeConfig ->isSetFlag (self ::RESERVATIONS_ENABLED_CONFIG_PATH , $ scopeType , $ scopeCode );
88
89
}
89
90
91
+ /**
92
+ * @param string $scopeType
93
+ * @param string|null $scopeCode
94
+ * @return bool
95
+ */
96
+ public function isReservationsCronEnabled (
97
+ string $ scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT ,
98
+ ?string $ scopeCode = null
99
+ ): bool {
100
+ return $ this ->scopeConfig ->isSetFlag (self ::RESERVATIONS_CRON_ENABLED_CONFIG_PATH , $ scopeType , $ scopeCode );
101
+ }
102
+
90
103
/**
91
104
* @return string|null
92
105
*/
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ public function cleanOldReservations()
173
173
{
174
174
$ tenDaysAgo = (new \DateTime ())->modify ('-10 day ' );
175
175
$ searchCriteria = $ this ->searchCriteriaBuilder
176
- ->addFilter ('created_at ' , $ tenDaysAgo-> format ( ' Y-m-d 12:00:00 ' ) , 'lteq ' )
176
+ ->addFilter ('created_at ' , $ tenDaysAgo , 'lteq ' )
177
177
->create ();
178
178
179
179
$ reservations = $ this ->reservationRepository ->getList ($ searchCriteria );
Original file line number Diff line number Diff line change 72
72
<label >Reservations enabled</label >
73
73
<source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
74
74
</field >
75
+ <field id =" reservations_cron_enabled" translate =" label" type =" select" sortOrder =" 30" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
76
+ <depends >
77
+ <field id =" reservations_enabled" >1</field >
78
+ </depends >
79
+ <label >Cron for cleaning old reservations enabled</label >
80
+ <comment >Cron deletes reservations older than 10 days</comment >
81
+ <source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
82
+ </field >
75
83
<field id =" store" translate =" label" type =" select" sortOrder =" 40" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
76
84
<label >Store to create new orders</label >
77
85
<source_model >Magento\Store\Model\System\Store</source_model >
Original file line number Diff line number Diff line change 15
15
<stock_synchronization_enabled >1</stock_synchronization_enabled >
16
16
<tracking_number_sending_enabled >1</tracking_number_sending_enabled >
17
17
<reservations_enabled >1</reservations_enabled >
18
+ <reservations_cron_enabled >0</reservations_cron_enabled >
18
19
<overpayment_status >Pending:allegro_overpayment</overpayment_status >
19
20
<underpayment_status >Pending:allegro_underpayment</underpayment_status >
20
21
</order >
Original file line number Diff line number Diff line change 71
71
<column xsi : type =" int" name =" reservation_id" padding =" 10" unsigned =" true" nullable =" false" identity =" false" comment =" Reservation ID" />
72
72
<column xsi : type =" varchar" name =" checkout_form_id" nullable =" false" comment =" Checkout form ID" />
73
73
<column xsi : type =" varchar" name =" sku" nullable =" false" comment =" Product SKU" />
74
- <column xsi : type =" datetime" name =" created_at" nullable =" false" comment =" Creation date" />
74
+ <column xsi : type =" datetime" name =" created_at" on_update = " false " nullable =" false" default = " CURRENT_TIMESTAMP " comment =" Creation date" />
75
75
<constraint xsi : type =" foreign" referenceId =" FOREIGN" table =" allegro_reservations" column =" reservation_id" referenceTable =" inventory_reservation" referenceColumn =" reservation_id" onDelete =" CASCADE" />
76
76
<constraint xsi : type =" primary" referenceId =" PRIMARY" >
77
77
<column name =" entity_id" />
Original file line number Diff line number Diff line change 172
172
"Reservation with ID: %1 has been successfully deleted","Rezerwacja o ID: %1 została pomyślnie usunięta"
173
173
"Something went wrong while trying to delete reservation with ID: %1","Coś poszło nie tak podczas próby usunięcia rezerwacji o ID: %1"
174
174
"Creation date","Data utworzenia"
175
+ "Cron for cleaning old reservations enabled","Cron do czyszczenia starych rezerwacji jest włączony"
176
+ "Cron deletes reservations older than 10 days","Cron usuwa rezerwacje starsze niż 10 dni"
You can’t perform that action at this time.
0 commit comments