mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Fix catalog notice on the first module install
This commit is contained in:
parent
0c072aea29
commit
bf52b020da
@ -45,7 +45,7 @@ class RetailcrmCatalogHelper
|
||||
$date = null;
|
||||
$filePath = self::getIcmlFilePath();
|
||||
if (!file_exists($filePath) || ($fileHandler = fopen($filePath, 'rb')) === false) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($line = fgets($fileHandler)) {
|
||||
@ -60,7 +60,7 @@ class RetailcrmCatalogHelper
|
||||
|
||||
fclose($fileHandler);
|
||||
|
||||
return $date;
|
||||
return DateTime::createFromFormat('Y-m-d H:i:s', $date);
|
||||
}
|
||||
|
||||
public static function getIcmlFileLink()
|
||||
@ -91,29 +91,32 @@ class RetailcrmCatalogHelper
|
||||
{
|
||||
$icmlInfo = json_decode((string)Configuration::get(self::ICML_INFO_NAME), true);
|
||||
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
if ($icmlInfo === null || json_last_error() !== JSON_ERROR_NONE) {
|
||||
$icmlInfo = array();
|
||||
}
|
||||
$lastGenerated = DateTime::createFromFormat('Y-m-d H:i:s', self::getIcmlFileDate());
|
||||
|
||||
if ($lastGenerated instanceof DateTime) {
|
||||
$icmlInfo['lastGenerated'] = $lastGenerated;
|
||||
$now = new DateTime();
|
||||
/** @var DateInterval $diff */
|
||||
$diff = $lastGenerated->diff($now);
|
||||
$lastGenerated = self::getIcmlFileDate();
|
||||
|
||||
$icmlInfo['lastGeneratedDiff'] = array(
|
||||
'days' => $diff->days,
|
||||
'hours' => $diff->h,
|
||||
'minutes' => $diff->i
|
||||
);
|
||||
|
||||
$icmlInfo['isOutdated'] = (
|
||||
$icmlInfo['lastGeneratedDiff']['days'] > 0
|
||||
|| $icmlInfo['lastGeneratedDiff']['hours'] > 4
|
||||
);
|
||||
if ($lastGenerated === false) {
|
||||
return $icmlInfo;
|
||||
}
|
||||
|
||||
$icmlInfo['lastGenerated'] = $lastGenerated;
|
||||
$now = new DateTime();
|
||||
/** @var DateInterval $diff */
|
||||
$diff = $lastGenerated->diff($now);
|
||||
|
||||
$icmlInfo['lastGeneratedDiff'] = array(
|
||||
'days' => $diff->days,
|
||||
'hours' => $diff->h,
|
||||
'minutes' => $diff->i
|
||||
);
|
||||
|
||||
$icmlInfo['isOutdated'] = (
|
||||
$icmlInfo['lastGeneratedDiff']['days'] > 0
|
||||
|| $icmlInfo['lastGeneratedDiff']['hours'] > 4
|
||||
);
|
||||
|
||||
$api = RetailcrmTools::getApiClient();
|
||||
|
||||
if ($api !== null) {
|
||||
@ -126,7 +129,7 @@ class RetailcrmCatalogHelper
|
||||
}
|
||||
}
|
||||
|
||||
return (array)$icmlInfo;
|
||||
return $icmlInfo;
|
||||
}
|
||||
|
||||
public static function getIcmlFileInfoMultistore()
|
||||
|
@ -1274,7 +1274,7 @@ class RetailCRM extends Module
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($icmlInfo['isOutdated'] || !$icmlInfo['isUrlActual']) {
|
||||
} elseif ($icmlInfo['isOutdated'] || (isset($icmlInfo['isUrlActual']) && $icmlInfo['isUrlActual'] === false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user