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 @@ -17,6 +17,7 @@ class Configuration
17
17
const PRICE_ATTRIBUTE_CONFIG_PATH = 'allegro/offer_create/price_attribute ' ;
18
18
const STORE_ID_CONFIG_PATH = 'allegro/order/store ' ;
19
19
const RESERVATIONS_ENABLED_CONFIG_PATH = 'allegro/order/reservations_enabled ' ;
20
+ const RESERVATIONS_CRON_ENABLED_CONFIG_PATH = 'allegro/order/reservations_cron_enabled ' ;
20
21
const PRICE_POLICY_ENABLED_CONFIG_PATH = 'allegro/price_policy/price_policy_enabled ' ;
21
22
const PERCENT_INCREASE_CONFIG_PATH = 'allegro/price_policy/percent_increase ' ;
22
23
const LAST_EVENT_ID_FLAG_NAME = 'allegro_order_last_event_id ' ;
@@ -90,6 +91,18 @@ public function areReservationsEnabled(
90
91
return $ this ->scopeConfig ->isSetFlag (self ::RESERVATIONS_ENABLED_CONFIG_PATH , $ scopeType , $ scopeCode );
91
92
}
92
93
94
+ /**
95
+ * @param string $scopeType
96
+ * @param string|null $scopeCode
97
+ * @return bool
98
+ */
99
+ public function isReservationsCronEnabled (
100
+ string $ scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT ,
101
+ ?string $ scopeCode = null
102
+ ): bool {
103
+ return $ this ->scopeConfig ->isSetFlag (self ::RESERVATIONS_CRON_ENABLED_CONFIG_PATH , $ scopeType , $ scopeCode );
104
+ }
105
+
93
106
/**
94
107
* @param string $scopeType
95
108
* @param string|null $scopeCode
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 177
177
"Product attribute for getting price","Atrybut produktu do pobrania ceny"
178
178
"Attributes are taken from the default scope","Atrybuty są pobierane z domyślnego widoku sklepu"
179
179
"Creation date","Data utworzenia"
180
+ "Cron for cleaning old reservations enabled","Cron do czyszczenia starych rezerwacji jest włączony"
181
+ "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