Skip to content

Commit

Permalink
Catalog sync enabled for commerce partner integration id (#417)
Browse files Browse the repository at this point in the history
* Catalog sync enabled for commerce partner integration id

* Catalog sync enable flag moved to separate function

* equality checks updated

* Static issue resolved
  • Loading branch information
singhramanpreett authored Sep 5, 2023
1 parent c1cee22 commit c100f2d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function executeForJson()
->saveCatalogId($catalogId, $storeId)
->saveCommercePartnerIntegrationId($commercePartnerIntegrationId, $storeId)
->saveInstalledFlag($storeId)
->completeOnsiteOnboarding($accessToken, $pageId, $storeId);
->completeOnsiteOnboarding($accessToken, $pageId, $storeId)
->enableCatalogSync($commercePartnerIntegrationId, $storeId);

$response['success'] = true;
$response['message'] = 'Configuration successfully saved';
Expand Down Expand Up @@ -147,6 +148,27 @@ public function saveCommercePartnerIntegrationId($commercePartnerIntegrationId,
return $this;
}

/**
* Based on commerce PI presence it enables catalog sync.
*
* @param int $commercePartnerIntegrationId
* @param int $storeId
* @return $this
*/
public function enableCatalogSync($commercePartnerIntegrationId, $storeId)
{
if ($commercePartnerIntegrationId) {
$this->fbeHelper->log(sprintf('Catalog sync is enabled for store %s', $storeId));

$this->systemConfig->saveConfig(
SystemConfig::XML_PATH_FACEBOOK_ENABLE_CATALOG_SYNC,
true,
$storeId
);
}
return $this;
}

/**
* Save external business id
*
Expand Down
4 changes: 2 additions & 2 deletions app/code/Meta/Catalog/Setup/Patch/Data/AddCatalogSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ private function updateStoreCatalogIntegration($storeId): void
'facebook/catalog_management/out_of_stock_threshold'
);

if ($isCatalogSyncEnabled == null) {
if ($isCatalogSyncEnabled === null && $isDailyFeedSyncEnabled !== null) {
$connection->insert($coreConfigTable, [
'scope' => $storeId ? 'stores' : 'default',
'scope_id' => $storeId,
'path' => SystemConfig::XML_PATH_FACEBOOK_ENABLE_CATALOG_SYNC,
'value' => $isDailyFeedSyncEnabled === null ? true : $isDailyFeedSyncEnabled,
'value' => $isDailyFeedSyncEnabled,
]);
}

Expand Down

0 comments on commit c100f2d

Please sign in to comment.