Skip to content

Commit 8018b2b

Browse files
committed
Merge branch 'master' of github.com:macopedia/magento2-allegro
2 parents 5ebcf25 + c64f9d9 commit 8018b2b

File tree

7 files changed

+28
-4
lines changed

7 files changed

+28
-4
lines changed

Cron/CleanReservations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
class CleanReservations
1515
{
16-
const RESERVATIONS_CONFIG_KEY = 'allegro/order/reservations_enabled';
16+
const RESERVATIONS_CRON_CONFIG_KEY = 'allegro/order/reservations_cron_enabled';
1717

1818
/** @var Logger */
1919
private $logger;
@@ -41,7 +41,7 @@ public function __construct(
4141

4242
public function execute()
4343
{
44-
if ($this->scopeConfig->getValue(self::RESERVATIONS_CONFIG_KEY)) {
44+
if ($this->scopeConfig->getValue(self::RESERVATIONS_CRON_CONFIG_KEY)) {
4545
$this->logger->addInfo("Cronjob clean reservations is executed.");
4646
$this->allegroReservation->cleanOldReservations();
4747
}

Model/Configuration.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Configuration
1717
const PRICE_ATTRIBUTE_CONFIG_PATH = 'allegro/offer_create/price_attribute';
1818
const STORE_ID_CONFIG_PATH = 'allegro/order/store';
1919
const RESERVATIONS_ENABLED_CONFIG_PATH = 'allegro/order/reservations_enabled';
20+
const RESERVATIONS_CRON_ENABLED_CONFIG_PATH = 'allegro/order/reservations_cron_enabled';
2021
const PRICE_POLICY_ENABLED_CONFIG_PATH = 'allegro/price_policy/price_policy_enabled';
2122
const PERCENT_INCREASE_CONFIG_PATH = 'allegro/price_policy/percent_increase';
2223
const LAST_EVENT_ID_FLAG_NAME = 'allegro_order_last_event_id';
@@ -90,6 +91,18 @@ public function areReservationsEnabled(
9091
return $this->scopeConfig->isSetFlag(self::RESERVATIONS_ENABLED_CONFIG_PATH, $scopeType, $scopeCode);
9192
}
9293

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+
93106
/**
94107
* @param string $scopeType
95108
* @param string|null $scopeCode

Model/OrderImporter/AllegroReservation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function cleanOldReservations()
173173
{
174174
$tenDaysAgo = (new \DateTime())->modify('-10 day');
175175
$searchCriteria = $this->searchCriteriaBuilder
176-
->addFilter('created_at', $tenDaysAgo->format('Y-m-d 12:00:00'), 'lteq')
176+
->addFilter('created_at', $tenDaysAgo, 'lteq')
177177
->create();
178178

179179
$reservations = $this->reservationRepository->getList($searchCriteria);

etc/adminhtml/system.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@
7272
<label>Reservations enabled</label>
7373
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
7474
</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>
7583
<field id="store" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
7684
<label>Store to create new orders</label>
7785
<source_model>Magento\Store\Model\System\Store</source_model>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<stock_synchronization_enabled>1</stock_synchronization_enabled>
1616
<tracking_number_sending_enabled>1</tracking_number_sending_enabled>
1717
<reservations_enabled>1</reservations_enabled>
18+
<reservations_cron_enabled>0</reservations_cron_enabled>
1819
<overpayment_status>Pending:allegro_overpayment</overpayment_status>
1920
<underpayment_status>Pending:allegro_underpayment</underpayment_status>
2021
</order>

etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<column xsi:type="int" name="reservation_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Reservation ID"/>
7272
<column xsi:type="varchar" name="checkout_form_id" nullable="false" comment="Checkout form ID"/>
7373
<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"/>
7575
<constraint xsi:type="foreign" referenceId="FOREIGN" table="allegro_reservations" column="reservation_id" referenceTable="inventory_reservation" referenceColumn="reservation_id" onDelete="CASCADE"/>
7676
<constraint xsi:type="primary" referenceId="PRIMARY">
7777
<column name="entity_id"/>

i18n/pl_PL.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,5 @@
177177
"Product attribute for getting price","Atrybut produktu do pobrania ceny"
178178
"Attributes are taken from the default scope","Atrybuty są pobierane z domyślnego widoku sklepu"
179179
"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"

0 commit comments

Comments
 (0)