Skip to content

Commit 794eb30

Browse files
Merge branch '1.0.1-rc' of github.com:magento-commerce/facebook-for-magento2 into 1.0.1-merge
Conflicts: app/code/Meta/Catalog/composer.json app/code/Meta/Conversion/composer.json app/code/Meta/Promotions/composer.json app/code/Meta/Sales/composer.json
2 parents 24e17b6 + 3ed5711 commit 794eb30

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

app/code/Meta/BusinessExtension/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "magento2-module",
55
"license": "Apache-2.0",
66
"require": {
7-
"php": "~8.1.0||~8.2.0",
7+
"php": "~8.1.0",
88
"ext-json": "*",
99
"magento/framework": "*",
1010
"magento/module-backend": "*",

app/code/Meta/Catalog/Block/Adminhtml/Product/Form/Diagnostics.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,16 @@ public function setProduct(ProductInterface $product)
114114
* @return array
115115
* @throws GuzzleException
116116
*/
117-
private function getFacebookProductDiagnostics()
117+
private function getFacebookProductDiagnostics(): array
118118
{
119+
// @todo #269 Missing catalog ID for product diagnostics
120+
$catalogId = $this->systemConfig->getCatalogId($this->storeId);
121+
if (!$catalogId) {
122+
return [];
123+
}
124+
119125
try {
120126
$retailerId = $this->productIdentifier->getMagentoProductRetailerId($this->product);
121-
$catalogId = $this->systemConfig->getCatalogId($this->storeId);
122127
$product = $this->graphApiAdapter->getProductByRetailerId($catalogId, $retailerId);
123128
$fbProductId = $product['data'][0]['id'] ?? false;
124129
if ($fbProductId) {

app/code/Meta/Catalog/Observer/Product/DeleteAfter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ private function deleteProduct($storeId, $product): void
113113
{
114114
$isActive = $this->systemConfig->isActiveExtension($storeId);
115115
$shouldIncrement = $this->systemConfig->isActiveIncrementalProductUpdates($storeId);
116+
$catalogId = $this->systemConfig->getCatalogId($storeId);
116117

117-
if (!($isActive && $shouldIncrement)) {
118+
if (!($isActive && $shouldIncrement && $catalogId)) {
118119
return;
119120
}
120121

@@ -126,7 +127,6 @@ private function deleteProduct($storeId, $product): void
126127
];
127128
$this->graphApiAdapter->setDebugMode($this->systemConfig->isDebugMode($storeId))
128129
->setAccessToken($this->systemConfig->getAccessToken($storeId));
129-
$catalogId = $this->systemConfig->getCatalogId($storeId);
130130
$this->graphApiAdapter->catalogBatchRequest($catalogId, [$requestData]);
131131
} catch (GuzzleException $e) {
132132
$this->messageManager->addErrorMessage(

app/code/Meta/Catalog/Observer/Product/SaveAfter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ private function updateProduct($storeId, $productId): void
124124
{
125125
$isActive = $this->systemConfig->isActiveExtension($storeId);
126126
$shouldIncrement = $this->systemConfig->isActiveIncrementalProductUpdates($storeId);
127+
$catalogId = $this->systemConfig->getCatalogId($storeId);
127128

128-
if (!($isActive && $shouldIncrement)) {
129+
if (!($isActive && $shouldIncrement && $catalogId)) {
129130
return;
130131
}
131132

@@ -140,7 +141,6 @@ private function updateProduct($storeId, $productId): void
140141
// @todo implement async call
141142
$this->graphApiAdapter->setDebugMode($this->systemConfig->isDebugMode($storeId))
142143
->setAccessToken($this->systemConfig->getAccessToken($storeId));
143-
$catalogId = $this->systemConfig->getCatalogId($storeId);
144144
$requestData = $this->batchApi->buildRequestForIndividualProduct($product);
145145
$this->graphApiAdapter->catalogBatchRequest($catalogId, [$requestData]);
146146
} catch (NoSuchEntityException $e) {

app/code/Meta/Catalog/Test/Unit/Observer/ProcessProductAfterDeleteEventObserverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public function testExecution()
116116
{
117117
$this->systemConfig->method('isActiveExtension')->willReturn(true);
118118
$this->systemConfig->method('isActiveIncrementalProductUpdates')->willReturn(true);
119+
$this->systemConfig->method('getCatalogId')->willReturn("12345");
120+
$this->_graphApi->method('setDebugMode')->willReturn($this->_graphApi);
119121
$this->_graphApi->expects($this->atLeastOnce())->method('catalogBatchRequest');
120122
$this->systemConfig->method('isActiveExtension')->willReturn(true);
121123
$this->processProductAfterDeleteEventObserver->execute($this->_eventObserverMock);

app/code/Meta/Catalog/Test/Unit/Observer/ProcessProductAfterSaveEventObserverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public function testExecute(): void
124124

125125
$productMock->method('getSendToFacebook')->willReturn(1);
126126

127+
$this->graphApiAdapterMock->method('setDebugMode')->willReturn($this->graphApiAdapterMock);
128+
127129
$this->systemConfigMock->method('getCatalogId')->willReturn("12345");
128130

129131
$this->batchApiMock->expects($this->once())

app/code/Meta/Sales/Observer/Order/Cancel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ private function cancelOrder(int $storeId, string $fbOrderId)
102102
} catch (GuzzleException $e) {
103103
$response = $e->getResponse();
104104
$body = json_decode($response->getBody());
105-
throw new Exception('Error Code: '
106-
.(string) $body->error->code
107-
.'; '
108-
. (string) $body->error->error_user_msg);
105+
throw new Exception(__(
106+
'Error code: "%1"; Error message: "%2"',
107+
(string)$body->error->code,
108+
(string)($body->error->message ?? $body->error->error_user_msg)
109+
));
109110
}
110111
}
111112
}

app/code/Meta/Sales/Observer/Order/MarkAsShipped.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ public function execute(Observer $observer)
9898
} catch (GuzzleException $e) {
9999
$response = $e->getResponse();
100100
$body = json_decode($response->getBody());
101-
throw new Exception('Error Code: '
102-
.(string) $body->error->code
103-
.'; '
104-
. (string) $body->error->error_user_msg);
101+
throw new Exception(__(
102+
'Error code: "%1"; Error message: "%2"',
103+
(string)$body->error->code,
104+
(string)($body->error->message ?? $body->error->error_user_msg)
105+
));
105106
}
106107
}
107108
}

app/code/Meta/Sales/Observer/Order/Refund.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ private function refundOrder(
174174
} catch (GuzzleException $e) {
175175
$response = $e->getResponse();
176176
$body = json_decode($response->getBody());
177-
throw new Exception('Error Code: '
178-
.(string) $body->error->code
179-
.'; '
180-
. (string) $body->error->error_user_msg);
177+
throw new Exception(__(
178+
'Error code: "%1"; Error message: "%2"',
179+
(string)$body->error->code,
180+
(string)($body->error->message ?? $body->error->error_user_msg)
181+
));
181182
}
182183
}
183184

0 commit comments

Comments
 (0)