Skip to content

Commit c100f2d

Browse files
Catalog sync enabled for commerce partner integration id (#417)
* Catalog sync enabled for commerce partner integration id * Catalog sync enable flag moved to separate function * equality checks updated * Static issue resolved
1 parent c1cee22 commit c100f2d

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public function executeForJson()
8686
->saveCatalogId($catalogId, $storeId)
8787
->saveCommercePartnerIntegrationId($commercePartnerIntegrationId, $storeId)
8888
->saveInstalledFlag($storeId)
89-
->completeOnsiteOnboarding($accessToken, $pageId, $storeId);
89+
->completeOnsiteOnboarding($accessToken, $pageId, $storeId)
90+
->enableCatalogSync($commercePartnerIntegrationId, $storeId);
9091

9192
$response['success'] = true;
9293
$response['message'] = 'Configuration successfully saved';
@@ -147,6 +148,27 @@ public function saveCommercePartnerIntegrationId($commercePartnerIntegrationId,
147148
return $this;
148149
}
149150

151+
/**
152+
* Based on commerce PI presence it enables catalog sync.
153+
*
154+
* @param int $commercePartnerIntegrationId
155+
* @param int $storeId
156+
* @return $this
157+
*/
158+
public function enableCatalogSync($commercePartnerIntegrationId, $storeId)
159+
{
160+
if ($commercePartnerIntegrationId) {
161+
$this->fbeHelper->log(sprintf('Catalog sync is enabled for store %s', $storeId));
162+
163+
$this->systemConfig->saveConfig(
164+
SystemConfig::XML_PATH_FACEBOOK_ENABLE_CATALOG_SYNC,
165+
true,
166+
$storeId
167+
);
168+
}
169+
return $this;
170+
}
171+
150172
/**
151173
* Save external business id
152174
*

app/code/Meta/Catalog/Setup/Patch/Data/AddCatalogSwitch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ private function updateStoreCatalogIntegration($storeId): void
101101
'facebook/catalog_management/out_of_stock_threshold'
102102
);
103103

104-
if ($isCatalogSyncEnabled == null) {
104+
if ($isCatalogSyncEnabled === null && $isDailyFeedSyncEnabled !== null) {
105105
$connection->insert($coreConfigTable, [
106106
'scope' => $storeId ? 'stores' : 'default',
107107
'scope_id' => $storeId,
108108
'path' => SystemConfig::XML_PATH_FACEBOOK_ENABLE_CATALOG_SYNC,
109-
'value' => $isDailyFeedSyncEnabled === null ? true : $isDailyFeedSyncEnabled,
109+
'value' => $isDailyFeedSyncEnabled,
110110
]);
111111
}
112112

0 commit comments

Comments
 (0)