Merge pull request #163 from Frosin/master

fixed synchronization when removing or adding products in retailCRM
This commit is contained in:
Alex Lushpai 2019-07-18 11:59:32 +03:00 committed by GitHub
commit 90e7c8913c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,15 +41,13 @@ class RetailcrmHistoryHelper {
$orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item']; $orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item'];
} }
if (isset($change['oldValue']) if (empty($change['oldValue'])
&& empty($change['oldValue'])
&& $change['field'] == 'order_product' && $change['field'] == 'order_product'
) { ) {
$orders[$change['order']['id']]['items'][$change['item']['id']]['create'] = true; $orders[$change['order']['id']]['items'][$change['item']['id']]['create'] = true;
} }
if (isset($change['newValue']) if (empty($change['newValue'])
&& empty($change['newValue'])
&& $change['field'] == 'order_product' && $change['field'] == 'order_product'
) { ) {
$orders[$change['order']['id']]['items'][$change['item']['id']]['delete'] = true; $orders[$change['order']['id']]['items'][$change['item']['id']]['delete'] = true;
@ -95,7 +93,7 @@ class RetailcrmHistoryHelper {
{ {
$customers = array(); $customers = array();
foreach ($customerHistory as $change) { foreach ($customerHistory as $change) {
$change['order'] = self::removeEmpty($change['customer']); $change['customer'] = self::removeEmpty($change['customer']);
if(!empty($customers[$change['customer']['id']]) && $customers[$change['customer']['id']]) { if(!empty($customers[$change['customer']['id']]) && $customers[$change['customer']['id']]) {
$customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']); $customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']);