mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Added skipping product\offer in ICML if filter result is an empty array. Added skipping segments' changes in back sync
This commit is contained in:
parent
1861b5255a
commit
7ade3ca00b
@ -295,7 +295,7 @@ class RetailcrmCatalog
|
||||
|
||||
unset($arComb);
|
||||
|
||||
yield RetailcrmTools::filter(
|
||||
$item = RetailcrmTools::filter(
|
||||
'RetailcrmFilterProcessOffer',
|
||||
$item,
|
||||
[
|
||||
@ -303,6 +303,10 @@ class RetailcrmCatalog
|
||||
'offer' => $offer,
|
||||
]
|
||||
);
|
||||
|
||||
if ([] !== $item) {
|
||||
yield $item;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
++$offersCount;
|
||||
@ -316,7 +320,9 @@ class RetailcrmCatalog
|
||||
$quantity = (int) StockAvailable::getQuantityAvailableByProduct($product['id_product']);
|
||||
}
|
||||
|
||||
$item = [
|
||||
$item = RetailcrmTools::filter(
|
||||
'RetailcrmFilterProcessOffer',
|
||||
[
|
||||
'id' => $product['id_product'],
|
||||
'productId' => $product['id_product'],
|
||||
'productActivity' => ($available_for_order) ? 'Y' : 'N',
|
||||
@ -333,15 +339,15 @@ class RetailcrmCatalog
|
||||
'weight' => $weight,
|
||||
'dimensions' => $dimensions,
|
||||
'vatRate' => $product['rate'],
|
||||
];
|
||||
|
||||
yield RetailcrmTools::filter(
|
||||
'RetailcrmFilterProcessOffer',
|
||||
$item,
|
||||
],
|
||||
[
|
||||
'product' => $product,
|
||||
]
|
||||
);
|
||||
|
||||
if ([] !== $item) {
|
||||
yield $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,8 @@ class RetailcrmHistory
|
||||
} else {
|
||||
self::createCustomerInPrestashop($customerHistory);
|
||||
}
|
||||
} catch (Error $e) {
|
||||
continue;
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
@ -811,7 +813,16 @@ class RetailcrmHistory
|
||||
$organizedHistory = [];
|
||||
$notOurChanges = [];
|
||||
|
||||
$fieldsToSkip = ['segments'];
|
||||
$fieldsToKeep = ['externalId', 'status'];
|
||||
|
||||
foreach ($historyEntries as $entry) {
|
||||
$field = $entry['field'];
|
||||
|
||||
if (in_array($field, $fieldsToSkip)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($entry[$recordType]['externalId'])) {
|
||||
if ('api' == $entry['source']
|
||||
&& isset($change['apiKey']['current'])
|
||||
@ -827,7 +838,6 @@ class RetailcrmHistory
|
||||
}
|
||||
|
||||
$externalId = $entry[$recordType]['externalId'];
|
||||
$field = $entry['field'];
|
||||
|
||||
if (!isset($organizedHistory[$externalId])) {
|
||||
$organizedHistory[$externalId] = [];
|
||||
@ -841,7 +851,7 @@ class RetailcrmHistory
|
||||
&& isset($entry['apiKey']['current'])
|
||||
&& true == $entry['apiKey']['current']
|
||||
) {
|
||||
if (isset($notOurChanges[$externalId][$field]) || 'externalId' == $field || 'status' == $field) {
|
||||
if (isset($notOurChanges[$externalId][$field]) || in_array($field, $fieldsToKeep)) {
|
||||
$organizedHistory[$externalId][] = $entry;
|
||||
}
|
||||
} else {
|
||||
|
@ -412,7 +412,7 @@ class RetailcrmJobManager
|
||||
*/
|
||||
private static function setLastRunDetails($lastRuns = [])
|
||||
{
|
||||
RetailcrmLogger::writeCaller(__METHOD__ . ':before', json_encode($lastRuns));
|
||||
RetailcrmLogger::writeDebug(__METHOD__ . ':before', json_encode($lastRuns));
|
||||
if (!is_array($lastRuns)) {
|
||||
$lastRuns = [];
|
||||
}
|
||||
@ -425,7 +425,7 @@ class RetailcrmJobManager
|
||||
}
|
||||
}
|
||||
|
||||
RetailcrmLogger::writeCaller(__METHOD__ . ':after', json_encode($lastRuns));
|
||||
RetailcrmLogger::writeDebug(__METHOD__ . ':after', json_encode($lastRuns));
|
||||
Configuration::updateGlobalValue(self::LAST_RUN_DETAIL_NAME, (string) json_encode($lastRuns));
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class RetailcrmIcmlUpdateUrlEvent extends RetailcrmAbstractEvent implements Reta
|
||||
}
|
||||
|
||||
$reference = new RetailcrmReferences($api);
|
||||
$site = $reference->getSite();
|
||||
$site = $reference->getSite(); // todo remove duplicated code
|
||||
if (empty($site)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class RetailcrmSettingsHelper
|
||||
if (null !== $api) {
|
||||
$reference = new RetailcrmReferences($api);
|
||||
|
||||
$site = $reference->getSite();
|
||||
$site = $reference->getSite(); // todo remove duplicated code
|
||||
$icmlInfo['isUrlActual'] = !empty($site['ymlUrl'])
|
||||
&& $site['ymlUrl'] === RetailcrmCatalogHelper::getIcmlFileLink();
|
||||
if (!empty($site['catalogId'])) {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user