Added loading catalog in CRM after ICML generation

This commit is contained in:
max-baranikov 2022-08-26 13:30:51 +03:00 committed by GitHub
parent c27a932f2e
commit 960ed4438a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 1 deletions

View File

@ -87,6 +87,34 @@ class RetailcrmCatalogHelper
return _PS_ROOT_DIR_ . '/' . self::getIcmlFileName();
}
public static function isIcmlFileLinkActual()
{
$api = RetailcrmTools::getApiClient();
if (empty($api)) {
return null;
}
$reference = new RetailcrmReferences($api);
$site = $reference->getSite();
if (empty($site)) {
return null;
}
$newYmlUrl = RetailcrmCatalogHelper::getIcmlFileLink();
RetailcrmLogger::writeDebug(
__METHOD__, sprintf(
'Comparing %s and %s: %s',
$newYmlUrl,
$site['ymlUrl'],
$newYmlUrl === $site['ymlUrl'] ? 'true' : 'false'
)
);
return $newYmlUrl === $site['ymlUrl'];
}
/**
* @param int $productsCount
* @param int $offersCount

View File

@ -61,6 +61,20 @@ class RetailcrmIcmlEvent extends RetailcrmAbstractEvent implements RetailcrmEven
$icml = new RetailcrmIcml($shop['name'], RetailcrmCatalogHelper::getIcmlFilePath());
$icml->generate($data[0], $data[1]);
if (true !== RetailcrmCatalogHelper::isIcmlFileLinkActual()) {
RetailcrmLogger::writeDebug(
__METHOD__,
'Skip statistic update due to non consistent ICML file link'
);
continue;
}
$api = RetailcrmTools::getApiClient();
if (null !== $api) {
$api->statisticUpdate();
}
}
return true;