Skip to content

Commit 3d4df5c

Browse files
sol-loupstrygo
andauthored
Update default config values (#482)
- Enabled catalog, order sync by default - Made order sync logic consistent - Fixed labels for syncing - Renamed method for consistency Co-authored-by: Steve Gordon <[email protected]>
1 parent 1ef90a6 commit 3d4df5c

File tree

11 files changed

+18
-22
lines changed

11 files changed

+18
-22
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,16 @@ public function getOutOfStockThreshold($scopeId = null, $scope = null)
393393
}
394394

395395
/**
396-
* Is active order sync
396+
* Is order sync enabled
397397
*
398398
* @param int $scopeId
399399
* @param int $scope
400400
* @return bool
401401
*/
402-
public function isActiveOrderSync($scopeId = null, $scope = null): bool
402+
public function isOrderSyncEnabled($scopeId = null, $scope = null): bool
403403
{
404-
return (bool)$this->getConfig(self::XML_PATH_FACEBOOK_ORDERS_SYNC_ACTIVE, $scopeId, $scope);
404+
return $this->getConfig(self::XML_PATH_FACEBOOK_ORDERS_SYNC_ACTIVE, $scopeId, $scope) &&
405+
$this->getConfig(self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE, $scopeId, $scope);
405406
}
406407

407408
/**
@@ -819,7 +820,8 @@ public function isCatalogSyncEnabled($scopeId = null, $scope = ScopeInterface::S
819820
*/
820821
public function isPromotionsSyncEnabled($scopeId = null, $scope = ScopeInterface::SCOPE_STORES): bool
821822
{
822-
return !!$this->getConfig(self::XML_PATH_FACEBOOK_ENABLE_PROMOTIONS_SYNC, $scopeId, $scope);
823+
return $this->getConfig(self::XML_PATH_FACEBOOK_ENABLE_PROMOTIONS_SYNC, $scopeId, $scope) &&
824+
$this->getConfig(self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE, $scopeId, $scope);
823825
}
824826

825827
/**

app/code/Meta/Catalog/Setup/MetaCatalogAttributes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getProductAttributes(): array
3838
'send_to_facebook' => [
3939
'group' => 'General',
4040
'type' => 'int',
41-
'label' => 'Send to Facebook',
41+
'label' => 'Sync to Meta',
4242
'default' => 1,
4343
'source' => Boolean::class,
4444
'input' => 'select',
@@ -65,7 +65,7 @@ public function getCategoryAttributes(): array
6565
return [
6666
SystemConfig::CATEGORY_SYNC_TO_FACEBOOK => [
6767
'type' => 'int',
68-
'label' => 'Sync to Facebook Catalog',
68+
'label' => 'Sync to Meta',
6969
'input' => 'boolean',
7070
'source' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class,
7171
'visible' => true,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
<default>
44
<facebook>
55
<catalog_management>
6-
<enable_catalog_sync>0</enable_catalog_sync>
6+
<enable_catalog_sync>1</enable_catalog_sync>
77
<price_incl_tax>0</price_incl_tax>
8-
<collections_sync>0</collections_sync>
98
<out_of_stock_threshold>0</out_of_stock_threshold>
109
</catalog_management>
1110
</facebook>

app/code/Meta/Sales/Controller/Adminhtml/Ajax/PullOrders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function executeForJson(): array
8383
$storeId = $storeParam;
8484
}
8585

86-
if (!$this->systemConfig->isActiveOrderSync($storeId)) {
86+
if (!$this->systemConfig->isOrdersSyncEnabled($storeId)) {
8787
$response['success'] = false;
8888
$response['error_message'] = __('Enable order sync before pulling orders.');
8989
return $response;

app/code/Meta/Sales/Cron/SyncOrders.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public function __construct(
7979
*/
8080
private function pullOrdersForStore(int $storeId)
8181
{
82-
if (!($this->systemConfig->isActiveExtension($storeId)
83-
&& $this->systemConfig->isActiveOrderSync($storeId)
82+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
8483
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
8584
return;
8685
}

app/code/Meta/Sales/Cron/SyncRefundsAndCancellations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public function __construct(
7979
*/
8080
private function pullRefundsAndCancellationsForStore(int $storeId)
8181
{
82-
if (!($this->systemConfig->isActiveExtension($storeId)
83-
&& $this->systemConfig->isActiveOrderSync($storeId))) {
82+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
83+
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
8484
return;
8585
}
8686

app/code/Meta/Sales/Observer/Facebook/OrderCreateAfter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public function execute(Observer $observer)
9494
$facebookOrder = $observer->getEvent()->getFacebookOrder();
9595
$storeId = $order->getStoreId();
9696

97-
if (!($this->systemConfig->isActiveExtension($storeId)
98-
&& $this->systemConfig->isActiveOrderSync($storeId)
97+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
9998
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
10099
return;
101100
}

app/code/Meta/Sales/Observer/Order/Cancel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public function execute(Observer $observer)
6969
$order = $observer->getEvent()->getOrder();
7070
$storeId = $order->getStoreId();
7171

72-
if (!($this->systemConfig->isActiveExtension($storeId)
73-
&& $this->systemConfig->isActiveOrderSync($storeId)
72+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
7473
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
7574
return;
7675
}

app/code/Meta/Sales/Observer/Order/MarkAsShipped.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ public function execute(Observer $observer)
8888
return;
8989
}
9090

91-
if (!($this->systemConfig->isActiveExtension($storeId)
92-
&& $this->systemConfig->isActiveOrderSync($storeId)
91+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
9392
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
9493
return;
9594
}

app/code/Meta/Sales/Observer/Order/Refund.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ public function execute(Observer $observer)
109109

110110
$storeId = $payment->getOrder()->getStoreId();
111111

112-
if (!($this->systemConfig->isActiveExtension($storeId)
113-
&& $this->systemConfig->isActiveOrderSync($storeId)
112+
if (!($this->systemConfig->isOrdersSyncEnabled($storeId)
114113
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
115114
return;
116115
}

0 commit comments

Comments
 (0)