Skip to content

Commit 10ce03a

Browse files
authored
Stabilize main (#232)
* Revert "Separate Ads and Commerce configs (#210)" This reverts commit f79c029. * Revert "change configuration and catalog diagnostics based on if fbe is installed (#220)" This reverts commit 9fc52d9. * Revert "remove choosing to upload inventory-- always true (#218)" This reverts commit d7b8aa0. * Revert "Change isInstalled step (#219)" This reverts commit de25343. * Revert "Remove choosing feed methods (#216)" This reverts commit a883e2d.
1 parent bc7d084 commit 10ce03a

File tree

31 files changed

+220
-283
lines changed

31 files changed

+220
-283
lines changed

app/code/Meta/BusinessExtension/Block/Adminhtml/System/Config/ModuleInfo.php

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
class ModuleInfo extends Field
2626
{
27-
private const EVENTS_MANAGER_URL = 'https://www.facebook.com/events_manager2';
2827
/**
2928
* Template path
3029
*
@@ -96,22 +95,62 @@ private function getStoreId()
9695
}
9796

9897
/**
99-
* Retrieve Pixel Id
98+
* Retrieve Commerce Account Id
10099
*
101100
* @return string
102101
*/
103-
public function getPixelId()
102+
public function getCommerceAccountId()
104103
{
105-
return $this->systemConfig->getPixelId($this->getStoreId());
104+
return $this->systemConfig->getCommerceAccountId($this->getStoreId());
106105
}
107106

108107
/**
109-
* Get events manager URL
108+
* Retrieve Page Id
110109
*
111110
* @return string
112111
*/
113-
public function getEventsManagerUrl()
112+
public function getPageId()
114113
{
115-
return self::EVENTS_MANAGER_URL;
114+
return $this->systemConfig->getPageId($this->getStoreId());
115+
}
116+
117+
/**
118+
* Retrieve Catalog Id
119+
*
120+
* @return string
121+
*/
122+
public function getCatalogId()
123+
{
124+
return $this->systemConfig->getCatalogId($this->getStoreId());
125+
}
126+
127+
/**
128+
* Retrieve Commerce Manager Url
129+
*
130+
* @return string
131+
*/
132+
public function getCommerceManagerUrl()
133+
{
134+
return $this->systemConfig->getCommerceManagerUrl($this->getStoreId());
135+
}
136+
137+
/**
138+
* Retrieve Catalog Manager Url
139+
*
140+
* @return string
141+
*/
142+
public function getCatalogManagerUrl()
143+
{
144+
return $this->systemConfig->getCatalogManagerUrl($this->getStoreId());
145+
}
146+
147+
/**
148+
* Retrieve Support Url
149+
*
150+
* @return string
151+
*/
152+
public function getSupportUrl()
153+
{
154+
return $this->systemConfig->getSupportUrl($this->getStoreId());
116155
}
117156
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function executeForJson()
7777
$pixelId,
7878
$storeId
7979
);
80+
$this->systemConfig->saveConfig(
81+
SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_INSTALLED,
82+
true,
83+
$storeId
84+
);
8085
$response['success'] = true;
8186
$response['pixelId'] = $pixelId;
8287
if ($oldPixelId && $oldPixelId != $pixelId) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ public function executeForJson()
8282
->saveCatalogId($catalogId, $storeId)
8383
->completeOnsiteOnboarding($accessToken, $pageId, $storeId);
8484

85-
$this->systemConfig->saveConfig(
86-
SystemConfig::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_INSTALLED,
87-
true,
88-
$storeId
89-
);
90-
9185
$response['success'] = true;
9286
$response['message'] = 'Configuration successfully saved';
9387
return $response;

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Config
3535
private const VERSION_CACHE_KEY = 'meta-business-extension-version';
3636
private const EXTENSION_PACKAGE_NAME = 'meta/meta-for-magento2';
3737

38-
private const XML_PATH_FACEBOOK_SHOPS_ACTIVE = 'facebook/business_extension/commerce';
38+
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE = 'facebook/business_extension/active';
3939
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_INSTALLED = 'facebook/business_extension/installed';
4040

4141
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_EXTERNAL_BUSINESS_ID =
@@ -56,6 +56,7 @@ class Config
5656
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_STORE = 'facebook/business_extension/store';
5757

5858
private const XML_PATH_FACEBOOK_DAILY_PRODUCT_FEED = 'facebook/catalog_management/daily_product_feed';
59+
private const XML_PATH_FACEBOOK_FEED_UPLOAD_METHOD = 'facebook/catalog_management/feed_upload_method';
5960
private const XML_PATH_FACEBOOK_PRODUCT_IDENTIFIER = 'facebook/catalog_management/product_identifier';
6061
private const XML_PATH_FACEBOOK_PRICE_INCL_TAX = 'facebook/catalog_management/price_incl_tax';
6162
private const XML_PATH_FACEBOOK_COLLECTIONS_SYNC_IS_ACTIVE = 'facebook/catalog_management/collections_sync';
@@ -71,6 +72,7 @@ class Config
7172
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_INCREMENTAL_PRODUCT_UPDATES =
7273
'facebook/catalog_management/incremental_product_updates';
7374

75+
private const XML_PATH_FACEBOOK_ENABLE_INVENTORY_UPLOAD = 'facebook/inventory_management/enable_inventory_upload';
7476
private const XML_PATH_FACEBOOK_USE_MULTI_SOURCE_INVENTORY =
7577
'facebook/inventory_management/use_multi_source_inventory';
7678
private const XML_PATH_FACEBOOK_INVENTORY_STOCK = 'facebook/inventory_management/inventory_stock';
@@ -263,9 +265,9 @@ public function isSingleStoreMode(): bool
263265
* @param string $scope
264266
* @return bool
265267
*/
266-
public function isActiveShop($scopeId = null, $scope = ScopeInterface::SCOPE_STORES): bool
268+
public function isActiveExtension($scopeId = null, $scope = ScopeInterface::SCOPE_STORES): bool
267269
{
268-
return (bool)$this->getConfig(self::XML_PATH_FACEBOOK_SHOPS_ACTIVE, $scopeId, $scope);
270+
return (bool)$this->getConfig(self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE, $scopeId, $scope);
269271
}
270272

271273
/**
@@ -337,6 +339,18 @@ public function isActiveIncrementalProductUpdates($scopeId = null, $scope = null
337339
);
338340
}
339341

342+
/**
343+
* Is active inventory upload
344+
*
345+
* @param int $scopeId
346+
* @param int $scope
347+
* @return bool
348+
*/
349+
public function isActiveInventoryUpload($scopeId = null, $scope = null): bool
350+
{
351+
return (bool)$this->getConfig(self::XML_PATH_FACEBOOK_ENABLE_INVENTORY_UPLOAD, $scopeId, $scope);
352+
}
353+
340354
/**
341355
* Use multi source inventory
342356
*
@@ -565,7 +579,7 @@ public function disableExtensionForNonDefaultStores()
565579
$defaultStoreId = $storeManager->getDefaultStoreView()->getId();
566580
foreach ($storeManager->getStores() as $store) {
567581
if ($store->getId() !== $defaultStoreId) {
568-
$this->saveConfig(self::XML_PATH_FACEBOOK_SHOPS_ACTIVE, 0, $store->getId());
582+
$this->saveConfig(self::XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE, 0, $store->getId());
569583
}
570584
}
571585
}
@@ -751,6 +765,18 @@ public function isActiveDailyProductFeed($scopeId = null, $scope = ScopeInterfac
751765
return (bool)$this->getConfig(self::XML_PATH_FACEBOOK_DAILY_PRODUCT_FEED, $scopeId, $scope);
752766
}
753767

768+
/**
769+
* Get feed upload method
770+
*
771+
* @param int $scopeId
772+
* @param string $scope
773+
* @return mixed
774+
*/
775+
public function getFeedUploadMethod($scopeId = null, $scope = ScopeInterface::SCOPE_STORES)
776+
{
777+
return $this->getConfig(self::XML_PATH_FACEBOOK_FEED_UPLOAD_METHOD, $scopeId, $scope);
778+
}
779+
754780
/**
755781
* Get feed id
756782
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getIdentity()
6868
public function isDisplayed()
6969
{
7070
$storeId = $this->request->getParam('store');
71-
if (!($this->systemConfig->isActiveShop($storeId)
71+
if (!($this->systemConfig->isActiveExtension($storeId)
7272
&& $this->systemConfig->getAccessToken($storeId)
7373
&& $this->systemConfig->isOnsiteCheckoutEnabled($storeId))) {
7474
return false;

app/code/Meta/BusinessExtension/Test/Mftf/Data/FacebookBusinessConfigData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
55
<entity name="FacebookBusinessConfigDataEnabled">
6-
<data key="path">facebook/business_extension/commerce</data>
6+
<data key="path">facebook/business_extension/active</data>
77
<data key="scope">store</data>
88
<data key="scope_code">default</data>
99
</entity>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
module="Meta_BusinessExtension"
2525
parent="Meta_BusinessExtension::facebook"
2626
sortOrder="20"
27-
dependsOnConfig="facebook/business_extension/installed"
28-
action="adminhtml/system_config/edit/section/ads_management"
27+
dependsOnModule="Meta_BusinessExtension"
28+
action="adminhtml/system_config/edit/section/facebook_business_extension"
2929
resource="Meta_BusinessExtension::facebook"/>
3030
</menu>
3131
</config>

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
<tab id="facebook" translate="label" sortOrder="1000">
55
<label>Meta</label>
66
</tab>
7-
<section id="ads_management" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
7+
<section id="facebook_business_extension" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
88
<class>separator-top</class>
9-
<label>Ads</label>
9+
<label>Business Extension</label>
1010
<tab>facebook</tab>
1111
<resource>Meta_BusinessExtension::system_config</resource>
1212
<group id="business_extension" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
1313
<label>Setup</label>
1414
<fieldset_css>meta-section-config</fieldset_css>
1515
<attribute type="expanded">1</attribute>
16-
<field id="module_info" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="1">
17-
<label>Module Info</label>
18-
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\ModuleInfo</frontend_model>
16+
<field id="active" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
17+
<label>Activate Integration</label>
18+
<config_path>facebook/business_extension/active</config_path>
19+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1920
</field>
20-
<field id="installed" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="1">
21-
<config_path>facebook/business_extension/installed</config_path>
21+
<field id="onsite" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="1">
22+
<config_path>facebook/business_extension/onsite</config_path>
2223
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2324
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\Field\Hidden</frontend_model>
2425
</field>
@@ -27,16 +28,20 @@
2728
<config_path>facebook/business_extension/pixel_id</config_path>
2829
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\Field\Hidden</frontend_model>
2930
</field>
31+
<field id="module_info" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="1">
32+
<label>Module Info</label>
33+
<depends>
34+
<field id="facebook_business_extension/business_extension/active">1</field>
35+
</depends>
36+
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\ModuleInfo</frontend_model>
37+
</field>
3038
</group>
31-
</section>
32-
<section id="meta_advanced" translate="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="1">
33-
<class>separator-top</class>
34-
<label>Advanced</label>
35-
<tab>facebook</tab>
36-
<resource>Meta_BusinessExtension::system_config</resource>
3739
<group id="debug" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="1">
3840
<label>Debug</label>
3941
<fieldset_css>meta-section-config</fieldset_css>
42+
<depends>
43+
<field id="facebook_business_extension/business_extension/active">1</field>
44+
</depends>
4045
<field id="debug_mode" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
4146
<label>Enable Debug Mode</label>
4247
<config_path>facebook/debug/debug_mode</config_path>

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
<business_extension>
66
<active>1</active>
77
<onsite>0</onsite>
8-
<installed>0</installed>
98
</business_extension>
109
<debug>
1110
<debug_mode>1</debug_mode>
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
<?php
22
/**
3-
* @var \Meta\BusinessExtension\Block\Adminhtml\System\Config\ModuleInfo $block
3+
* @var Meta\BusinessExtension\Block\Adminhtml\System\Config\ModuleInfo $block
44
* @var $escaper \Magento\Framework\Escaper
55
*/
66
?>
77
<div>
88
<p>Version: <?= $escaper->escapeHtml($block->getModuleVersion()) ?></p>
9-
<p>Pixel ID: <?= $escaper->escapeHtml($block->getPixelId()) ?></p>
10-
<p><a target="_blank"
11-
href="<?= $escaper->escapeUrl($block->getEventsManagerUrl()) ?> ">
12-
<?= $escaper->escapeHtml(__('Events Manager')) ?>
13-
</a>
14-
</p>
9+
<p>Commerce Account ID: <?= $escaper->escapeHtml($block->getCommerceAccountId()) ?></p>
10+
<p>Page ID: <?= $escaper->escapeHtml($block->getPageId()) ?></p>
11+
<p>Catalog ID: <?= $escaper->escapeHtml($block->getCatalogId()) ?></p>
12+
<?php if ($block->getCommerceAccountId()): ?>
13+
<p><a target="_blank"
14+
href="<?= $escaper->escapeUrl($block->getCommerceManagerUrl()) ?> ">
15+
<?= $escaper->escapeHtml(__('Commerce Manager')) ?>
16+
</a>
17+
</p>
18+
<?php endif; ?>
19+
<?php if ($block->getCatalogId()): ?>
20+
<p><a target="_blank"
21+
href="<?= $escaper->escapeUrl($block->getCatalogManagerUrl()) ?> ">
22+
<?= $escaper->escapeHtml(__('Catalog Items')) ?>
23+
</a>
24+
</p>
25+
<?php endif; ?>
26+
<?php if ($block->getCommerceAccountId()): ?>
27+
<p><a target="_blank"
28+
href="<?= $escaper->escapeUrl($block->getSupportUrl()) ?> ">
29+
<?= $escaper->escapeHtml(__('Contact Support')) ?>
30+
</a>
31+
</p>
32+
<?php endif; ?>
1533
</div>

0 commit comments

Comments
 (0)