Skip to content

Commit 9a6679d

Browse files
authored
Merge pull request #7 from saleslayer/develop
Develop
2 parents 30bfaad + 11437ef commit 9a6679d

File tree

8 files changed

+502
-959
lines changed

8 files changed

+502
-959
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [2.6.2] - 2023-07-24
4+
5+
### Added
6+
7+
- Function to obtain a non-used category URL Key when synchronizing category data on each store.
8+
9+
### Changed
10+
11+
- Auto Sync correction for connectors configured with 24h or more.
12+
- Pagination improvements.
13+
- Minor fixes.
14+
315
## [2.6.1] - 2023-02-17
416

517
### Added

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ php bin/magento cache:clean
6363

6464
## Version Guidance
6565

66-
| Version | Status | Magento Version (Adobe Commerce) | Recommended Configuration |
67-
|---------|----------------|----------------------------------|----------------------------|
68-
| 2.5.x | EOL | >= 2.4.1, <= 2.4.3 | Magento 2.4.3 / PHP 7.4 |
69-
| 2.6.0 | Stable | >= 2.4.3, <= 2.4.5 | Magento 2.4.5-p1 / PHP 8.1 |
70-
| 2.6.1 | Latest | >= 2.4.3, <= 2.4.5 | Magento 2.4.5-p1 / PHP 8.1 |
66+
| Version | Status | Magento Version (Adobe Commerce) | Recommended Configuration |
67+
|-----------------|----------------|----------------------------------|----------------------------|
68+
| 2.5.x | EOL | >= 2.4.1, <= 2.4.3 | Magento 2.4.3 / PHP 7.4 |
69+
| 2.6.0 - 2.6.1 | Stable | >= 2.4.3, <= 2.4.5 | Magento 2.4.5-p1 / PHP 8.1 |
70+
| 2.6.2 | Latest | >= 2.4.3, <= 2.4.5 | Magento 2.4.5-p1 / PHP 8.1 |
7171

7272
> **Warning**.
7373
> Adobe releases frequently new Magento Open Source versions, fixing bugs and/or adding new functionallity. Some of this versions could be in conflict with this plugin. We highly encourage you to set up the configuration recommended in the guidance table for running correctly this extension.

Saleslayer/Synccatalog/Block/Adminhtml/Synccatalog/Edit/Tab/Parameters.php

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Saleslayer\Synccatalog\Block\Adminhtml\Synccatalog\Edit\Tab;
33

4+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
5+
46
// use \Magento\Catalog\Model\Category as categoryModel;
57

68
/**
@@ -25,10 +27,12 @@ public function __construct(
2527
\Magento\Framework\Registry $registry,
2628
\Magento\Framework\Data\FormFactory $formFactory,
2729
\Magento\Store\Model\System\Store $systemStore,
30+
TimezoneInterface $timezone,
2831
array $data = []
2932
) {
3033
parent::__construct($context, $registry, $formFactory, $data);
3134
$this->_systemStore = $systemStore;
35+
$this->timezone = $timezone;
3236
}
3337

3438
/**
@@ -55,25 +59,28 @@ protected function _prepareForm()
5559
$modelData = $model->getData();
5660

5761
if (empty($modelData)){
58-
$modelData['store_view_ids'] = array('0') ;
62+
$modelData['store_view_ids'] = ['0'] ;
5963
}else{
6064
$modelData['store_view_ids'] = json_decode($modelData['store_view_ids'],1);
6165
}
6266

63-
$auto_sync_options = array();
64-
$auto_sync_values = array(0, 1, 3, 6, 8, 12, 15, 24, 48, 72);
67+
$auto_sync_options = [];
68+
$auto_sync_values = [0, 1, 3, 6, 8, 12, 15, 24, 48, 72];
69+
6570
foreach ($auto_sync_values as $auto_sync_value) {
6671
if ($auto_sync_value == 0){
67-
array_push($auto_sync_options, array('label' => ' ', 'value' => $auto_sync_value));
72+
array_push($auto_sync_options, ['label' => ' ', 'value' => $auto_sync_value]);
6873
}else{
69-
array_push($auto_sync_options, array('label' => $auto_sync_value.'H', 'value' => $auto_sync_value));
74+
array_push($auto_sync_options, ['label' => $auto_sync_value.'H', 'value' => $auto_sync_value]);
7075
}
7176
}
7277

78+
$datetime_last_sync = '';
79+
7380
if(!empty($modelData['last_sync'])){
74-
$time_lapsed = '<br><small>Since last sync of this connector step: '.$this->elapsed_time(strtotime( $modelData['last_sync'])).'</small>';
75-
}else{
76-
$time_lapsed = '';
81+
$last_sync_timezoned = $this->timezone->date($modelData['last_sync'])->format('M d, Y, H:i:s A');
82+
$datetime_last_sync = "<br><small>Connector's last auto-synchronization: ".$last_sync_timezoned."</small>";
83+
$datetime_last_sync .= "<br><small><strong>*Note: This synchronization will be executed according to the server time.</strong></small>";
7784
}
7885

7986
$fieldset->addField(
@@ -87,21 +94,24 @@ protected function _prepareForm()
8794
'required' => false,
8895
'values' => $auto_sync_options,
8996
'disabled' => false,
90-
'after_element_html' =>$time_lapsed,
97+
'after_element_html' => $datetime_last_sync,
9198
'class' => 'conn_field'
9299
]
93100
);
94101

95-
if(!empty($modelData) && isset($modelData['auto_sync']) && $modelData['auto_sync']>= 24){
102+
if (!empty($modelData) && isset($modelData['auto_sync']) && $modelData['auto_sync'] >= 24){
96103
$hour_input_disabled = false;
97104
}else{
98105
$hour_input_disabled = true;
99106
}
100107

101-
$auto_sync_hour_options = array();
108+
$auto_sync_hour_options = [];
102109
$hours_range = range(0, 23);
103-
foreach($hours_range as $hour){
104-
$auto_sync_hour_options[$hour] = array('label' => (strlen($hour) == 1 ? '0'.$hour : $hour).':00', 'value' => $hour);
110+
foreach ($hours_range as $hour){
111+
$auto_sync_hour_options[$hour] = [
112+
'label' => (strlen($hour) == 1 ? '0'.$hour : $hour).':00',
113+
'value' => $hour
114+
];
105115
}
106116

107117
$fieldset->addField(
@@ -152,21 +162,6 @@ protected function _prepareForm()
152162

153163
return parent::_prepareForm();
154164
}
155-
private function elapsed_time($timestamp, $precision = 2) {
156-
$time = time() - $timestamp;
157-
$result = '';
158-
$a = array('decade' => 315576000, 'year' => 31557600, 'month' => 2629800, 'week' => 604800, 'day' => 86400, 'hour' => 3600, 'min' => 60, 'sec' => 1);
159-
$i = 0;
160-
foreach($a as $k => $v) {
161-
$$k = floor($time/$v);
162-
if ($$k) $i++;
163-
$time = $i >= $precision ? 0 : $time - $$k * $v;
164-
$s = $$k > 1 ? 's' : '';
165-
$$k = $$k ? $$k.' '.$k.$s.' ' : '';
166-
$result .= $$k;
167-
}
168-
return $result ? $result.'ago' : '1 sec to go';
169-
}
170165

171166
/**
172167
* Prepare label for tab

Saleslayer/Synccatalog/Model/Autosynccron.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function auto_sync_connectors(){
263263
if ($connector['auto_sync'] > 0){
264264

265265
$connector_last_sync = $connector['last_sync'];
266-
$connector_last_sync_unix = strtotime($connector_last_sync);
266+
$connector_last_sync_unix = strtotime($connector_last_sync ?? 0);
267267

268268
$unix_to_update = $now - ($connector['auto_sync'] * 3600);
269269

@@ -278,7 +278,8 @@ public function auto_sync_connectors(){
278278

279279
$unix_to_update_hour = mktime($connector['auto_sync_hour'],0,0,date('m', $unix_to_update),date('d', $unix_to_update),date('Y', $unix_to_update));
280280

281-
if ($connector_last_sync_unix < $unix_to_update_hour){
281+
if ($connector_last_sync_unix < $unix_to_update &&
282+
$unix_to_update_hour <= $now){
282283

283284
$connector['unix_to_update'] = $unix_to_update_hour;
284285
$connectors_to_check[] = $connector;
@@ -307,6 +308,8 @@ public function auto_sync_connectors(){
307308
if ($connector['auto_sync'] >= 24){
308309

309310
$last_sync_time = mktime($connector['auto_sync_hour'],0,0,date('m', $now),date('d', $now),date('Y', $now));
311+
if ($last_sync_time > $now) $last_sync_time -= ($connector['auto_sync'] * 3600);
312+
310313
$last_sync = date('Y-m-d H:i:s', $last_sync_time);
311314

312315
}else{
@@ -397,8 +400,6 @@ public function auto_sync_connectors(){
397400
private function delete_sl_logs_since_days(){
398401

399402
if (in_array($this->delete_sl_logs_since_days, array('', null, 0))) return false;
400-
401-
$time_ini_delete_sl_logs = microtime(1);
402403

403404
$log_folder_files = scandir($this->sl_logs_path);
404405

@@ -443,8 +444,6 @@ private function delete_sl_logs_since_days(){
443444

444445
}
445446

446-
// $this->debbug('##### time_delete_sl_logs: '.(microtime(1) - $time_ini_delete_sl_logs).' seconds');
447-
448447
}
449448

450449
}

0 commit comments

Comments
 (0)