Skip to content

Commit 725f7f7

Browse files
committed
Merge branch 'main' into 1.2.2-rc
2 parents fd2bebc + d844aaa commit 725f7f7

18 files changed

+568
-409
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# the repo. Unless a later match takes precedence,
66
# @global-owner1 and @global-owner2 will be requested for
77
# review when someone opens a pull request.
8-
* @zlik @dabramovici @sol-loup @camcuz97 @agmurari @yang17 @nrostrow-meta @dalongi @yangssr @palak-ana @n-nayak @singhramanpreett @luizmramosmeta @cristiannancumeta @singhalavi @jczhuoMeta
8+
* @zlik @dabramovici @sol-loup @camcuz97 @agmurari @yang17 @nrostrow-meta @dalongi @palak-ana @n-nayak @singhramanpreett @luizmramosmeta @cristiannancumeta @singhalavi @jczhuoMeta @swinard-meta

app/code/Meta/BusinessExtension/Helper/FBEHelper.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,17 @@ public function log($info, array $context = [])
268268
return;
269269
}
270270

271+
$extraData = ['timestamp' => time()];
272+
271273
if (isset($context['store_id'])) {
274+
$extraData['store_id'] = $context['store_id'];
272275
$context['commerce_merchant_settings_id'] = $this->systemConfig->getCommerceAccountId($context['store_id']);
273276
}
274277

275-
$timestamp = ['timestamp' => time()];
276278
if (isset($context['extra_data'])) {
277-
$context['extra_data'] = array_merge($context['extra_data'], $timestamp);
279+
$context['extra_data'] = array_merge($context['extra_data'], $extraData);
278280
} else {
279-
$context['extra_data'] = $timestamp;
281+
$context['extra_data'] = $extraData;
280282
}
281283
$this->logger->info($info, $context);
282284
}
@@ -313,19 +315,19 @@ public function logException(Throwable $e, array $context = [])
313315
$context['exception_message'] = $errorMessage;
314316
$context['exception_code'] = $e->getCode();
315317
$context['exception_trace'] = $exceptionTrace;
318+
$context['seller_platform_app_version'] = $this->getMagentoVersion();
319+
320+
$extraData = ['extension_version' => $this->systemConfig->getModuleVersion()];
316321

317322
if (isset($context['store_id'])) {
323+
$extraData['store_id'] = $context['store_id'];
318324
$context['commerce_merchant_settings_id'] = $this->systemConfig->getCommerceAccountId($context['store_id']);
319325
}
320326

321-
$context['seller_platform_app_version'] = $this->getMagentoVersion();
322-
323-
// Add extension version to the extra data.
324-
$extensionVersion = ['extension_version' => $this->systemConfig->getModuleVersion()];
325327
if (isset($context['extra_data'])) {
326-
$context['extra_data'] = array_merge($context['extra_data'], $extensionVersion);
328+
$context['extra_data'] = array_merge($context['extra_data'], $extraData);
327329
} else {
328-
$context['extra_data'] = $extensionVersion;
330+
$context['extra_data'] = $extraData;
329331
}
330332

331333
$this->logger->error($errorMessage, $context);

app/code/Meta/BusinessExtension/Helper/GraphAPIAdapter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,13 +932,14 @@ public function getFBEInstalls($accessToken, $externalBusinessId)
932932
* Persist log to Meta
933933
*
934934
* @param mixed[] $context
935+
* @param null|string $accessToken
935936
* @return mixed
936937
* @throws GuzzleException
937938
*/
938-
public function persistLogToMeta($context)
939+
public function persistLogToMeta($context, $accessToken = null)
939940
{
940941
$request = [
941-
'access_token' => $this->accessToken,
942+
'access_token' => $accessToken ?? $this->accessToken,
942943
'event' => $this->getContextData($context, 'event'),
943944
'event_type' => $this->getContextData($context, 'event_type'),
944945
'commerce_merchant_settings_id' => $this->getContextData($context, 'commerce_merchant_settings_id'),

app/code/Meta/BusinessExtension/Model/PersistMetaLogImmediatelyHandler.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
namespace Meta\BusinessExtension\Model;
2222

2323
use Meta\BusinessExtension\Helper\GraphAPIAdapter;
24+
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
2425

2526
class PersistMetaLogImmediatelyHandler
2627
{
@@ -30,15 +31,23 @@ class PersistMetaLogImmediatelyHandler
3031
*/
3132
private $graphApiAdapter;
3233

34+
/**
35+
* @var SystemConfig
36+
*/
37+
private $systemConfig;
38+
3339
/**
3440
* PersistMetaLogImmediatelyHandler constructor
3541
*
3642
* @param GraphAPIAdapter $graphAPIAdapter
43+
* @param SystemConfig $systemConfig
3744
*/
3845
public function __construct(
39-
GraphAPIAdapter $graphAPIAdapter
46+
GraphAPIAdapter $graphAPIAdapter,
47+
SystemConfig $systemConfig
4048
) {
4149
$this->graphApiAdapter = $graphAPIAdapter;
50+
$this->systemConfig = $systemConfig;
4251
}
4352

4453
/**
@@ -49,6 +58,10 @@ public function __construct(
4958
public function persistMetaLogImmediately(string $message)
5059
{
5160
$context = json_decode($message, true);
52-
$this->graphApiAdapter->persistLogToMeta($context);
61+
$accessToken = null;
62+
if ($context['store_id']) {
63+
$accessToken = $this->systemConfig->getAccessToken($context['store_id']);
64+
}
65+
$this->graphApiAdapter->persistLogToMeta($context, $accessToken);
5366
}
5467
}

app/code/Meta/BusinessExtension/Model/PersistMetaTelemetryLogsHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function __construct(
4848
*/
4949
public function persistMetaTelemetryLogs(string $messages)
5050
{
51+
$telemetryContext = [];
5152
$telemetryContext['event'] = 'persist_meta_telemetry_logs';
5253
$telemetryContext['extra_data']['telemetry_logs'] = $messages;
5354
$this->graphApiAdapter->persistLogToMeta($telemetryContext);

app/code/Meta/Catalog/Controller/Adminhtml/Ajax/CategoryUpload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use Meta\BusinessExtension\Controller\Adminhtml\Ajax\AbstractAjax;
2626
use Meta\BusinessExtension\Helper\FBEHelper;
2727
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
28-
use Meta\Catalog\Model\Feed\CategoryCollection;
28+
use Meta\Catalog\Model\Category\CategoryCollection;
2929

3030
class CategoryUpload extends AbstractAjax
3131
{

app/code/Meta/Catalog/Cron/CategorySyncCron.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
use Meta\BusinessExtension\Helper\FBEHelper;
2424
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
25-
use Meta\Catalog\Model\Feed\CategoryCollection;
25+
use Meta\Catalog\Model\Category\CategoryCollection;
2626

2727
class CategorySyncCron
2828
{

app/code/Meta/Catalog/Cron/LogCatalogSetup.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,33 @@ public function execute()
9393
continue;
9494
}
9595

96-
$this->graphAPIAdapter->persistLogToMeta([
97-
'event' => 'log_catalog_setup_data',
98-
'event_type' => 'log_catalog_setup',
99-
'catalog_id' => $this->systemConfig->getCatalogId($storeId),
100-
'commerce_merchant_settings_id' => $this->systemConfig->getCommerceAccountId($storeId),
101-
'extra_data' => [
102-
'items' => json_encode(
103-
[
104-
'item_count' => $this->queryItemCount(),
105-
'group_count' => $this->queryGroupCount(),
106-
'breakdown' => $this->queryBreakdown(),
107-
]
108-
),
109-
'extensions' => self::$logInstalledModules
96+
$this->graphAPIAdapter->persistLogToMeta(
97+
[
98+
'event' => 'log_catalog_setup_data',
99+
'event_type' => 'log_catalog_setup',
100+
'catalog_id' => $this->systemConfig->getCatalogId($storeId),
101+
'commerce_merchant_settings_id' => $this->systemConfig->getCommerceAccountId($storeId),
102+
'extra_data' => [
103+
'items' => json_encode(
104+
[
105+
'item_count' => $this->queryItemCount(),
106+
'group_count' => $this->queryGroupCount(),
107+
'breakdown' => $this->queryBreakdown(),
108+
]
109+
),
110+
'extensions' => self::$logInstalledModules
110111
? json_encode($this->fullModuleList->getAll())
111112
: null
112-
]
113-
]);
113+
]
114+
],
115+
$accessToken
116+
);
114117
} catch (\Exception $e) {
115-
$this->fbeHelper->logExceptionImmediatelyToMeta($e, [
118+
$this->fbeHelper->logExceptionImmediatelyToMeta($e, [
116119
'store_id' => $storeId,
117120
'event' => 'log_catalog_setup_cron_exception',
118121
'event_type' => 'log_catalog_setup'
119-
]);
122+
]);
120123
}
121124
}
122125
}

app/code/Meta/Catalog/Helper/CatalogSyncHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
use Meta\BusinessExtension\Helper\FBEHelper;
2424
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
25-
use Meta\Catalog\Model\Feed\CategoryCollection;
25+
use Meta\Catalog\Model\Category\CategoryCollection;
2626
use Meta\Catalog\Model\Product\Feed\Uploader;
2727

2828
class CatalogSyncHelper

app/code/Meta/Catalog/Helper/Product/Identifier.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ public function __construct(SystemConfig $systemConfig, ProductRepository $produ
4949
$this->productRepository = $productRepository;
5050
}
5151

52+
/**
53+
* Get product's identifier col name(SKU or entity ID, depending on configuration)
54+
*
55+
* @return string
56+
*/
57+
public function getProductIdentifierColName(): string
58+
{
59+
if ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_SKU) {
60+
return 'sku';
61+
} elseif ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_ID) {
62+
return 'entity_id';
63+
}
64+
return '';
65+
}
66+
5267
/**
5368
* Get product's identifier (SKU or ID, depending on configuration)
5469
*

0 commit comments

Comments
 (0)