Skip to content

Commit 79ed7d9

Browse files
carterbuceCarter Buce
andauthored
[GA Readiness] Remove onsite flag from config.xml (#685)
* initial commit * also removing isOnsiteCheckoutEnabled --------- Co-authored-by: Carter Buce <[email protected]>
1 parent 6cc34d0 commit 79ed7d9

File tree

17 files changed

+51
-161
lines changed

17 files changed

+51
-161
lines changed

app/code/Meta/BusinessExtension/Api/CoreConfigInterface.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ public function isCatalogSyncEnabled(): bool;
6969
*/
7070
public function setIsCatalogSyncEnabled(bool $val): void;
7171

72-
/**
73-
* IsOnsiteCheckoutEnabled Getter
74-
*
75-
* @return bool
76-
*/
77-
public function isOnsiteCheckoutEnabled(): bool;
78-
79-
/**
80-
* IsOnsiteCheckoutEnabled Setter
81-
*
82-
* @param bool $val
83-
* @return void
84-
*/
85-
public function setIsOnsiteCheckoutEnabled(bool $val): void;
86-
8772
/**
8873
* IsPromotionsSyncEnabled Getter
8974
*
@@ -129,21 +114,6 @@ public function getOutOfStockThreshold(): ?string;
129114
*/
130115
public function setOutOfStockThreshold(?string $val): void;
131116

132-
/**
133-
* IsCommerceExtensionEnabled Getter
134-
*
135-
* @return bool
136-
*/
137-
public function isCommerceExtensionEnabled(): bool;
138-
139-
/**
140-
* IsOnsiteCheckoutEnabled Setter
141-
*
142-
* @param bool $val
143-
* @return void
144-
*/
145-
public function setIsCommerceExtensionEnabled(bool $val): void;
146-
147117
/**
148118
* FeedId Getter
149119
*

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(
6161
*/
6262
public function getSplashPageURL()
6363
{
64-
if (!$this->systemConfig->isCommerceExtensionEnabled()) {
64+
if (!$this->systemConfig->isActiveExtension()) {
6565
return 'https://business.facebook.com/fbe-iframe-get-started/?';
6666
}
6767

@@ -76,7 +76,7 @@ public function getSplashPageURL()
7676
*/
7777
public function getPopupOrigin()
7878
{
79-
if (!$this->systemConfig->isCommerceExtensionEnabled()) {
79+
if (!$this->systemConfig->isActiveExtension()) {
8080
return 'https://business.facebook.com';
8181
}
8282

@@ -92,7 +92,7 @@ public function getPopupOrigin()
9292
public function isCommerceExtensionEnabled($storeId)
9393
{
9494
$storeHasCommercePartnerIntegration = !!$this->systemConfig->getCommercePartnerIntegrationId($storeId);
95-
return $storeHasCommercePartnerIntegration || $this->systemConfig->isCommerceExtensionEnabled();
95+
return $storeHasCommercePartnerIntegration || $this->systemConfig->isActiveExtension($storeId);
9696
}
9797

9898
/**

app/code/Meta/BusinessExtension/Model/Api/CoreConfig.php

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,6 @@ public function setIsCatalogSyncEnabled(bool $val): void
8888
$this->setData('isCatalogSyncEnabled', $val);
8989
}
9090

91-
/**
92-
* IsOnsiteCheckoutEnabled Getter
93-
*
94-
* @return bool
95-
*/
96-
public function isOnsiteCheckoutEnabled(): bool
97-
{
98-
return $this->_getData('isOnsiteCheckoutEnabled');
99-
}
100-
101-
/**
102-
* IsOnsiteCheckoutEnabled Setter
103-
*
104-
* @param bool $val
105-
* @return void
106-
*/
107-
public function setIsOnsiteCheckoutEnabled(bool $val): void
108-
{
109-
$this->setData('isOnsiteCheckoutEnabled', $val);
110-
}
111-
11291
/**
11392
* IsPromotionsSyncEnabled Getter
11493
*
@@ -172,33 +151,12 @@ public function setOutOfStockThreshold(?string $val): void
172151
$this->setData('outOfStockThreshold', $val);
173152
}
174153

175-
/**
176-
* IsCommerceExtensionEnabled Getter
177-
*
178-
* @return bool
179-
*/
180-
public function isCommerceExtensionEnabled(): bool
181-
{
182-
return $this->_getData('isCommerceExtensionEnabled');
183-
}
184-
185-
/**
186-
* IsOnsiteCheckoutEnabled Setter
187-
*
188-
* @param bool $val
189-
* @return void
190-
*/
191-
public function setIsCommerceExtensionEnabled(bool $val): void
192-
{
193-
$this->setData('isCommerceExtensionEnabled', $val);
194-
}
195-
196154
/**
197155
* FeedId Getter
198156
*
199157
* @return ?string
200158
*/
201-
public function getFeedId():?string
159+
public function getFeedId(): ?string
202160
{
203161
return $this->_getData('feedId');
204162
}

app/code/Meta/BusinessExtension/Model/Api/SettingsWebhookListenerImpl.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ class SettingsWebhookListenerImpl implements SettingsWebhookListenerInterface
9090
* @param MetaIssueNotification $issueNotification
9191
*/
9292
public function __construct(
93-
SystemConfig $systemConfig,
93+
SystemConfig $systemConfig,
9494
FBEHelper $fbeHelper,
9595
CollectionFactory $collectionFactory,
9696
Authenticator $authenticator,
97-
CatalogConfigUpdateHelper $catalogConfigUpdateHelper,
97+
CatalogConfigUpdateHelper $catalogConfigUpdateHelper,
9898
GraphAPIAdapter $graphApiAdapter,
99-
CoreConfigFactory $coreConfigFactory,
100-
MetaIssueNotification $issueNotification
99+
CoreConfigFactory $coreConfigFactory,
100+
MetaIssueNotification $issueNotification
101101
) {
102102
$this->systemConfig = $systemConfig;
103103
$this->fbeHelper = $fbeHelper;
@@ -124,6 +124,7 @@ public function processSettingsWebhookRequest(array $settingsWebhookRequest): vo
124124
$this->updateSetting($setting);
125125
}
126126
}
127+
127128
/**
128129
* Update notification in magento Admin page
129130
*
@@ -176,7 +177,7 @@ private function updateSetting(SettingsWebhookRequestInterface $setting): void
176177
);
177178
// Step 4 - Verify Catalog id updated correctly
178179
if ($this->systemConfig->getCatalogId((int)$storeId) !== $fbeResponse['catalog_id']) {
179-
$this->throwException('Catalog config update failed for external_business_id: '.$externalBusinessId);
180+
$this->throwException('Catalog config update failed for external_business_id: ' . $externalBusinessId);
180181
}
181182
} catch (Throwable $e) {
182183
$context = [
@@ -192,15 +193,15 @@ private function updateSetting(SettingsWebhookRequestInterface $setting): void
192193
/**
193194
* Get storeId
194195
*
195-
* @param string $externalBusinessId
196+
* @param string $externalBusinessId
196197
* @return string
197198
* @throws LocalizedException
198199
*/
199200
private function getStoreIdByExternalBusinessId(string $externalBusinessId): string
200201
{
201202
$installedConfigs = $this->getMBEInstalledConfigsByExternalBusinessId($externalBusinessId);
202203
if (empty($installedConfigs)) {
203-
$this->throwException('No store id is found for found for external_business_id: '.$externalBusinessId);
204+
$this->throwException('No store id is found for found for external_business_id: ' . $externalBusinessId);
204205
}
205206
// StoreId and externalBusinessId is 1:1 mapping, hence get $storeIds[0] as $storeId in below.
206207
return $installedConfigs[0]->getScopeId();
@@ -218,7 +219,7 @@ private function getMBESettings(int $storeId): array
218219
$accessToken = $this->systemConfig->getAccessToken($storeId);
219220
$businessId = $this->systemConfig->getExternalBusinessId($storeId);
220221
if (!$accessToken || !$businessId) {
221-
$this->throwException('AccessToken or BusinessID not found for storeID:'.$storeId);
222+
$this->throwException('AccessToken or BusinessID not found for storeID:' . $storeId);
222223
}
223224
$response = $this->graphApiAdapter->getFBEInstalls($accessToken, $businessId);
224225
if (!is_array($response) || empty($response)) {
@@ -286,7 +287,7 @@ public function getCoreConfig(string $externalBusinessId): CoreConfigInterface
286287
try {
287288
// Meta currently doesn't sign requests to settings sync APIS
288289
$this->authenticator->authenticateRequestDangerouslySkipSignatureValidation();
289-
$coreConfigData = $this->getCoreConfigByStoreId($externalBusinessId, $storeId);
290+
$coreConfigData = $this->getCoreConfigByStoreId($externalBusinessId, $storeId);
290291
$coreConfig->addData($coreConfigData);
291292
} catch (Exception $e) {
292293
$context = [
@@ -314,10 +315,9 @@ private function getCoreConfigByStoreId(string $externalBusinessId, string $stor
314315
'isOrderSyncEnabled' => $this->systemConfig->isOrderSyncEnabled($storeId),
315316
'isCatalogSyncEnabled' => $this->systemConfig->isCatalogSyncEnabled($storeId),
316317
'isPromotionsSyncEnabled' => $this->systemConfig->isPromotionsSyncEnabled($storeId),
317-
'isOnsiteCheckoutEnabled' => $this->systemConfig->isOnsiteCheckoutEnabled($storeId),
318+
'isActiveExtension' => $this->systemConfig->isActiveExtension($storeId),
318319
'productIdentifierAttr' => $this->systemConfig->getProductIdentifierAttr($storeId),
319320
'outOfStockThreshold' => $this->systemConfig->getOutOfStockThreshold($storeId),
320-
'isCommerceExtensionEnabled' => $this->systemConfig->isCommerceExtensionEnabled($storeId),
321321
'feedId' => $this->systemConfig->getFeedId($storeId),
322322
'installedMetaExtensionVersion' => $this->systemConfig->getModuleVersion(),
323323
'graphApiVersion' => $this->graphApiAdapter->getGraphApiVersion(),
@@ -331,7 +331,7 @@ private function getCoreConfigByStoreId(string $externalBusinessId, string $stor
331331
* @param string $graphApiVersion
332332
* @return void
333333
*/
334-
private function updateGraphAPIVersion(string $graphApiVersion) : void
334+
private function updateGraphAPIVersion(string $graphApiVersion): void
335335
{
336336
$this->systemConfig->saveConfig(
337337
SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_GRAPH_API_VERSION,

app/code/Meta/BusinessExtension/Model/System/Config.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ class Config
111111
'facebook/conversion_management/enable_server_test';
112112
private const XML_PATH_FACEBOOK_CONVERSION_MANAGEMENT_SERVER_TEST_CODE =
113113
'facebook/conversion_management/server_test_code';
114-
115-
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ENABLE_ONSITE_CHECKOUT_FLAG =
116-
'facebook/business_extension/onsite';
117-
118114
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ENABLE_MEMORY_PROFILING =
119115
'facebook/business_extension/enable_memory_profiling';
120116

@@ -319,22 +315,6 @@ public function isFBEInstalled($scopeId = null, $scope = ScopeInterface::SCOPE_S
319315
);
320316
}
321317

322-
/**
323-
* Is commerce extension UI update enabled
324-
*
325-
* @param int|null $scopeId
326-
* @param string $scope
327-
* @return bool
328-
*/
329-
public function isCommerceExtensionEnabled($scopeId = null, $scope = ScopeInterface::SCOPE_STORE): bool
330-
{
331-
return (bool)$this->getConfig(
332-
self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ENABLE_ONSITE_CHECKOUT_FLAG,
333-
$scopeId,
334-
$scope
335-
);
336-
}
337-
338318
/**
339319
* The base URL for rendering the Commerce Extension Splash page.
340320
*
@@ -351,22 +331,6 @@ public function getCommerceExtensionBaseURL($scopeId = null, $scope = ScopeInter
351331
) ?? 'https://www.commercepartnerhub.com/';
352332
}
353333

354-
/**
355-
* Is onsite checkout enabled
356-
*
357-
* @param int|null $scopeId
358-
* @param string $scope
359-
* @return bool
360-
*/
361-
public function isOnsiteCheckoutEnabled($scopeId = null, $scope = ScopeInterface::SCOPE_STORE): bool
362-
{
363-
return (bool)$this->getConfig(
364-
self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ENABLE_ONSITE_CHECKOUT_FLAG,
365-
$scopeId,
366-
$scope
367-
);
368-
}
369-
370334
/**
371335
* Get store manager
372336
*
@@ -886,7 +850,7 @@ public function getAllOnsiteFBEInstalledStores()
886850
return array_filter($stores, function ($store) {
887851
$scopeId = $store->getId();
888852
return $this->isPostOnboardingState($scopeId) &&
889-
$this->isOnsiteCheckoutEnabled($scopeId) &&
853+
$this->isActiveExtension($scopeId) &&
890854
// A slight nuance. You can be installed, but not "onsite" -- unless you have valid commerce account.
891855
$this->getCommerceAccountId($scopeId);
892856
});

app/code/Meta/BusinessExtension/Model/System/Message/Notification.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class Notification implements MessageInterface
4848
* @param RequestInterface $request
4949
*/
5050
public function __construct(
51-
SystemConfig $systemConfig,
52-
UrlInterface $urlBuilder,
51+
SystemConfig $systemConfig,
52+
UrlInterface $urlBuilder,
5353
RequestInterface $request
5454
) {
5555
$this->systemConfig = $systemConfig;
@@ -72,8 +72,7 @@ public function isDisplayed()
7272
{
7373
$storeId = $this->request->getParam('store');
7474
if (!($this->systemConfig->isActiveExtension($storeId)
75-
&& $this->systemConfig->getAccessToken($storeId)
76-
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
75+
&& $this->systemConfig->getAccessToken($storeId))) {
7776
return false;
7877
}
7978

app/code/Meta/BusinessExtension/etc/adminhtml/system.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<config_path>facebook/business_extension/active</config_path>
2323
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2424
</field>
25-
<field id="onsite" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="1">
26-
<config_path>facebook/business_extension/onsite</config_path>
27-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
28-
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\Field\Hidden</frontend_model>
29-
</field>
3025
<field id="commerce_extension" type="select" sortOrder="20" showInDefault="1" showInWebsite="0"
3126
showInStore="1">
3227
<config_path>facebook/business_extension/commerce_extension</config_path>
@@ -90,7 +85,7 @@
9085
<field id="facebook_business_extension/business_extension/active">1</field>
9186
</depends>
9287
<field id="manual_data_sync_empty" translate="label" type="note" sortOrder="16" showInDefault="1"
93-
showInWebsite="0" showInStore="1">
88+
showInWebsite="0" showInStore="1">
9489
<depends>
9590
<field id="facebook_business_extension/business_extension/installed">0</field>
9691
</depends>

app/code/Meta/BusinessExtension/etc/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<facebook>
66
<business_extension>
77
<active>1</active>
8-
<onsite>0</onsite>
98
<client_access_token>195311308289826|52dcd04d6c7ed113121b5eb4be23b4a7</client_access_token>
109
<enable_memory_profiling>0</enable_memory_profiling>
1110
</business_extension>

app/code/Meta/Conversion/Test/Mftf/Test/AddToCartPixelEventCreatedTest.xml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<!--suppress ALL -->
34
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
5+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
56
<test name="AddToCartPixelEventCreatedTest">
67
<annotations>
78
<features value="Pixel"/>
@@ -19,21 +20,25 @@
1920
</createData>
2021

2122
<!-- Add Pixel -->
22-
<magentoCLI command="config:set --scope={{FacebookBusinessConfigDataEnabled.scope}} --scope-code={{FacebookBusinessConfigDataEnabled.scope_code}} {{FacebookBusinessConfigDataEnabled.path}} 1"
23-
stepKey="enableFacebookBusinessExtension"/>
24-
<magentoCLI command="config:set --scope={{FacebookBusinessConfigDataPixelId.scope}} --scope-code={{FacebookBusinessConfigDataPixelId.scope_code}} {{FacebookBusinessConfigDataPixelId.path}} 123456789123456"
25-
stepKey="setFacebookBusinessExtensionPixelId"/>
23+
<magentoCLI
24+
command="config:set --scope={{FacebookBusinessConfigDataEnabled.scope}} --scope-code={{FacebookBusinessConfigDataEnabled.scope_code}} {{FacebookBusinessConfigDataEnabled.path}} 1"
25+
stepKey="enableFacebookBusinessExtension"/>
26+
<magentoCLI
27+
command="config:set --scope={{FacebookBusinessConfigDataPixelId.scope}} --scope-code={{FacebookBusinessConfigDataPixelId.scope_code}} {{FacebookBusinessConfigDataPixelId.path}} 123456789123456"
28+
stepKey="setFacebookBusinessExtensionPixelId"/>
2629
</before>
2730
<after>
2831
<!-- Delete sample product -->
2932
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
3033
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
3134

3235
<!-- Remove Pixel -->
33-
<magentoCLI command="config:set --scope={{FacebookBusinessConfigDataEnabled.scope}} --scope-code={{FacebookBusinessConfigDataEnabled.scope_code}} {{FacebookBusinessConfigDataEnabled.path}} 0"
34-
stepKey="disableFacebookBusinessExtension"/>
35-
<magentoCLI command="config:set --scope={{FacebookBusinessConfigDataPixelId.scope}} --scope-code={{FacebookBusinessConfigDataPixelId.scope_code}} {{FacebookBusinessConfigDataPixelId.path}} ''"
36-
stepKey="unsetFacebookBusinessExtensionPixelId"/>
36+
<magentoCLI
37+
command="config:set --scope={{FacebookBusinessConfigDataEnabled.scope}} --scope-code={{FacebookBusinessConfigDataEnabled.scope_code}} {{FacebookBusinessConfigDataEnabled.path}} 0"
38+
stepKey="disableFacebookBusinessExtension"/>
39+
<magentoCLI
40+
command="config:set --scope={{FacebookBusinessConfigDataPixelId.scope}} --scope-code={{FacebookBusinessConfigDataPixelId.scope_code}} {{FacebookBusinessConfigDataPixelId.path}} ''"
41+
stepKey="unsetFacebookBusinessExtensionPixelId"/>
3742
</after>
3843

3944
<!-- Navigate to Home page -->
@@ -45,7 +50,8 @@
4550
</actionGroup>
4651

4752
<!-- Submit add to cart form -->
48-
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"/>
53+
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup"
54+
stepKey="addToCartFromStorefrontProductPage"/>
4955

5056
<!-- Check pixel status element in dom on page -->
5157
<seeElementInDOM selector="{{StorefrontBodySection.PixelStatus}}" stepKey="seePixelStatusElement"/>

0 commit comments

Comments
 (0)