Skip to content

Commit 5109ac4

Browse files
arushipatel97Arushi Patel
andauthored
Pass storeID & adminURL to MBE (#821)
Co-authored-by: Arushi Patel <[email protected]>
1 parent cc548ae commit 5109ac4

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

app/code/Meta/BusinessExtension/Block/Adminhtml/Setup.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,26 @@ public function getAppId()
361361
return $this->systemConfig->getAppId();
362362
}
363363

364+
/**
365+
* Get client token
366+
*
367+
* @return string
368+
*/
369+
public function getClientToken()
370+
{
371+
return '52dcd04d6c7ed113121b5eb4be23b4a7';
372+
}
373+
374+
/**
375+
* Get access token
376+
*
377+
* @return string
378+
*/
379+
public function getAccessClientToken()
380+
{
381+
return $this->getAppId().'|'.$this->getClientToken();
382+
}
383+
364384
/**
365385
* Get stores that are selectable (not Admin).
366386
*

app/code/Meta/BusinessExtension/view/adminhtml/templates/setup.phtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ use Magento\Framework\Escaper;
3131
<?php else: ?>
3232
<script>
3333
window.facebookBusinessExtensionConfig = {
34+
accessClientToken: '<?= $escaper->escapeHtml($block->getAccessClientToken()) ?>',
3435
appId: '<?= $escaper->escapeHtml($block->getAppId()) ?>',
36+
adminUrl:'<?= $escaper->escapeHtml($this->getBaseUrl()) ?>',
3537
businessName: 'Magento',
3638
businessVertical: 'ECOMMERCE',
3739
channel: <?=$block->isCommerceExtensionEnabled() ? "'COMMERCE'" : "'COMMERCE_OFFSITE'"?>,
6 KB
Binary file not shown.

app/code/Meta/BusinessExtension/view/adminhtml/web/js/fbe_allinone.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ const ajaxify = function (url) {
3333

3434
const getAndEncodeExternalClientMetadata = function () {
3535
const metaData = {
36+
admin_url: window.facebookBusinessExtensionConfig.adminUrl,
3637
customer_token: window.facebookBusinessExtensionConfig.customApiKey,
3738
commerce_partner_seller_platform_type: window.facebookBusinessExtensionConfig.commerce_partner_seller_platform_type,
3839
shop_domain: window.facebookBusinessExtensionConfig.shopDomain,
3940
country_code: window.facebookBusinessExtensionConfig.countryCode,
40-
client_version: window.facebookBusinessExtensionConfig.extensionVersion
41+
client_version: window.facebookBusinessExtensionConfig.extensionVersion,
42+
platform_store_id: window.facebookBusinessExtensionConfig.storeId,
4143
};
4244
return encodeURIComponent(JSON.stringify(metaData));
4345
}
@@ -356,6 +358,7 @@ jQuery(document).ready(function () {
356358
queryParams: function queryParams()
357359
{
358360
return 'app_id=' + window.facebookBusinessExtensionConfig.appId +
361+
'&access_client_token=' + window.facebookBusinessExtensionConfig.accessClientToken +
359362
'&timezone=' + window.facebookBusinessExtensionConfig.timeZone +
360363
'&external_business_id=' + window.facebookBusinessExtensionConfig.externalBusinessId +
361364
'&installed=' + this.state.installed +
@@ -399,6 +402,7 @@ jQuery(document).ready(function () {
399402
document.getElementById('fbe-iframe-container')
400403
);
401404
});
405+
402406
},{"./react":3,"./react-dom":2,"./utils":4}],2:[function(require,module,exports){
403407
(function (global){(function (){
404408
/**

app/code/Meta/BusinessExtension/view/adminhtml/web/js/lib/fbe.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ const ajaxify = function (url) {
3232

3333
const getAndEncodeExternalClientMetadata = function () {
3434
const metaData = {
35+
admin_url: window.facebookBusinessExtensionConfig.adminUrl,
3536
customer_token: window.facebookBusinessExtensionConfig.customApiKey,
3637
commerce_partner_seller_platform_type: window.facebookBusinessExtensionConfig.commerce_partner_seller_platform_type,
3738
shop_domain: window.facebookBusinessExtensionConfig.shopDomain,
3839
country_code: window.facebookBusinessExtensionConfig.countryCode,
39-
client_version: window.facebookBusinessExtensionConfig.extensionVersion
40+
client_version: window.facebookBusinessExtensionConfig.extensionVersion,
41+
platform_store_id: window.facebookBusinessExtensionConfig.storeId,
4042
};
4143
return encodeURIComponent(JSON.stringify(metaData));
4244
}
@@ -355,6 +357,7 @@ jQuery(document).ready(function () {
355357
queryParams: function queryParams()
356358
{
357359
return 'app_id=' + window.facebookBusinessExtensionConfig.appId +
360+
'&access_client_token=' + window.facebookBusinessExtensionConfig.accessClientToken +
358361
'&timezone=' + window.facebookBusinessExtensionConfig.timeZone +
359362
'&external_business_id=' + window.facebookBusinessExtensionConfig.externalBusinessId +
360363
'&installed=' + this.state.installed +
@@ -397,4 +400,4 @@ jQuery(document).ready(function () {
397400
React.createElement(FBEFlowContainer, null),
398401
document.getElementById('fbe-iframe-container')
399402
);
400-
});
403+
});

0 commit comments

Comments
 (0)