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