Skip to content

Commit a33464f

Browse files
authored
Merge branch 'main' into ADO-449-categoryid-issue
2 parents f3d2920 + 3cccad6 commit a33464f

File tree

16 files changed

+188
-478
lines changed

16 files changed

+188
-478
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,6 @@ public function getAccessTokenAjaxRoute()
174174
return $this->fbeHelper->getUrl('fbeadmin/ajax/fbtoken');
175175
}
176176

177-
/**
178-
* Get profiles ajax route
179-
*
180-
* @return mixed
181-
*/
182-
public function getProfilesAjaxRoute()
183-
{
184-
return $this->fbeHelper->getUrl('fbeadmin/ajax/fbprofiles');
185-
}
186-
187177
/**
188178
* Get aam settings route
189179
*

app/code/Meta/BusinessExtension/Controller/Adminhtml/Ajax/Fbdeleteasset.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ private function deleteConfigKeys($storeId)
172172
->deleteConfig(SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_COMMERCE_ACCOUNT_ID, $storeId)
173173
->deleteConfig(SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PIXEL_ID, $storeId)
174174
->deleteConfig(SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PIXEL_AAM_SETTINGS, $storeId)
175-
->deleteConfig(SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PROFILES, $storeId)
176175
->deleteConfig(SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_CATALOG_ID, $storeId)
177176
->deleteConfig(
178177
SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_COMMERCE_PARTNER_INTEGRATION_ID,

app/code/Meta/BusinessExtension/Controller/Adminhtml/Ajax/Fbprofiles.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public function save($response, $storeId)
147147
);
148148

149149
$this->savePixelId($pixelId, $storeId);
150-
$this->saveProfiles($data['profiles'] ?? '', $storeId);
151150
$this->savePages($data['pages'] ?? '', $storeId);
152151
$this->saveCatalogId($catalogId, $storeId);
153152
$this->saveCommercePartnerIntegrationId($commercePartnerIntegrationId, $storeId);
@@ -186,25 +185,6 @@ private function savePixelId($pixelId, $storeId)
186185
}
187186
}
188187

189-
/**
190-
* Save profiles
191-
*
192-
* @param array $profiles
193-
* @param int $storeId
194-
*/
195-
private function saveProfiles($profiles, $storeId)
196-
{
197-
if ($profiles) {
198-
$profiles = json_encode($profiles);
199-
$this->systemConfig->saveConfig(
200-
SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PROFILES,
201-
$profiles,
202-
$storeId
203-
);
204-
$this->fbeHelper->log("Saved fbe_installs profiles --- {$profiles} for storeID: {$storeId}");
205-
}
206-
}
207-
208188
/**
209189
* Save pages
210190
*

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ class Config
4949
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PIXEL_ID = 'facebook/business_extension/pixel_id';
5050
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PIXEL_AAM_SETTINGS =
5151
'facebook/business_extension/pixel_aam_settings';
52-
53-
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PROFILES = 'facebook/business_extension/profiles';
54-
5552
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PAGE_ID = 'facebook/business_extension/page_id';
5653
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_CATALOG_ID = 'facebook/business_extension/catalog_id';
5754

@@ -158,7 +155,7 @@ class Config
158155
*
159156
* @var string|null
160157
*/
161-
private ?string $version = '1.4.3-dev';
158+
private ?string $version = '1.5.1-dev';
162159

163160
/**
164161
* Config class constructor
@@ -602,18 +599,6 @@ public function getPixelAamSettings($scopeId = null, $scope = null)
602599
);
603600
}
604601

605-
/**
606-
* Get profiles
607-
*
608-
* @param int $scopeId
609-
* @param int $scope
610-
* @return mixed
611-
*/
612-
public function getProfiles($scopeId = null, $scope = null)
613-
{
614-
return $this->getConfig(self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_PROFILES, $scopeId, $scope);
615-
}
616-
617602
/**
618603
* Get page id
619604
*

app/code/Meta/BusinessExtension/Test/Unit/Controller/Adminhtml/Ajax/FbprofilesTest.php

Lines changed: 0 additions & 127 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use Magento\Framework\Escaper;
6565
setAccessToken: '{$escaper->escapeHtml($block->getAccessTokenAjaxRoute()) }',
6666
setInstalledFeatures: '{$escaper->escapeHtml($block->getInstalledFeaturesAjaxRouteUrl()) }',
6767
setPixelId: '{$escaper->escapeHtml($block->getPixelAjaxRoute()) }',
68-
setProfilesData: '{$escaper->escapeHtml($block->getProfilesAjaxRoute()) }',
6968
storeId: '{$escaper->escapeHtml($block->getSelectedStoreId()) }',
7069
timeZone: '{$escaper->escapeHtml($block->getStoreTimezone()) }',
7170
countryCode: '{$escaper->escapeHtml($block->getStoreCountryCode()) }',

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ require(['jquery'], function (jQuery) {
7878
if (data.success) {
7979
msg = data.message;
8080
console.log("Update success");
81+
if (triggerPostOnboarding) {
82+
// Store sync info before reload
83+
sessionStorage.setItem('mbe_pending_post_onboarding_sync', JSON.stringify({
84+
storeId: window.facebookBusinessExtensionConfig.storeId,
85+
timestamp: new Date().getTime()
86+
}));
87+
}
8188
} else {
8289
msg = data.error_message;
8390
}
@@ -89,6 +96,42 @@ require(['jquery'], function (jQuery) {
8996
});
9097
}
9198

99+
// Add function to handle post-onboarding sync
100+
function handlePostReloadSync() {
101+
const pendingSyncData = sessionStorage.getItem('mbe_pending_post_onboarding_sync');
102+
if (pendingSyncData) {
103+
sessionStorage.removeItem('mbe_pending_post_onboarding_sync');
104+
try {
105+
const {storeId, timestamp} = JSON.parse(pendingSyncData);
106+
const SYNC_EXPIRY_MS = 30 * 60 * 1000; // 30 minutes
107+
if (new Date().getTime() - timestamp < SYNC_EXPIRY_MS) {
108+
console.log('Starting initial sync in the background');
109+
// Use setTimeout to ensure page is fully loaded
110+
setTimeout(function () {
111+
jQuery.ajax({
112+
type: 'post',
113+
url: ajaxify(window.facebookBusinessExtensionConfig.postFBEOnboardingSync),
114+
data: ajaxParam({
115+
storeId: storeId
116+
}),
117+
success: function (response) {
118+
console.log('Background sync completed successfully');
119+
},
120+
error: function (error) {
121+
console.error('Background sync failed:', error);
122+
}
123+
});
124+
}, 0);
125+
}
126+
} catch (e) {
127+
console.error('Error processing pending sync data:', e);
128+
}
129+
}
130+
}
131+
132+
// Initialize post-reload sync handling
133+
jQuery(document).ready(handlePostReloadSync);
134+
92135
function cleanConfigCacheAndReloadPage()
93136
{
94137
jQuery.ajax({

0 commit comments

Comments
 (0)