Skip to content

Commit a247b9f

Browse files
authored
Manual Data Sync: QOL Improvement (#558)
* Manual Data Sync: QOL Improve the manual data sync experience: 1. Always show the Manual Data Sync section 2. Show instructions to select a storeview if on default config 3. Show instructions to connect to Meta if not connected * Remove unused variable
1 parent a34d5df commit a247b9f

File tree

6 files changed

+103
-1
lines changed

6 files changed

+103
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright (c) Meta Platforms, Inc. and affiliates.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace Meta\BusinessExtension\Block\Adminhtml\System\Config;
19+
20+
use Magento\Backend\Block\Template\Context;
21+
use Magento\Config\Block\System\Config\Form\Field;
22+
use Magento\Framework\Data\Form\Element\AbstractElement;
23+
24+
class ManualDataSyncEmpty extends Field
25+
{
26+
/**
27+
* Template path
28+
*
29+
* @var string
30+
*/
31+
protected $_template = 'Meta_BusinessExtension::system/config/manual_data_sync_empty.phtml';
32+
33+
/**
34+
* @param Context $context
35+
* @param array $data
36+
*/
37+
public function __construct(
38+
Context $context,
39+
array $data = []
40+
) {
41+
parent::__construct($context, $data);
42+
}
43+
44+
/**
45+
* Remove scope label
46+
*
47+
* @param AbstractElement $element
48+
* @return string
49+
*/
50+
public function render(AbstractElement $element)
51+
{
52+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
53+
return parent::render($element);
54+
}
55+
56+
/**
57+
* Return element html
58+
*
59+
* @param AbstractElement $element
60+
* @return string
61+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
62+
*/
63+
protected function _getElementHtml(AbstractElement $element)
64+
{
65+
return $this->_toHtml();
66+
}
67+
68+
/**
69+
* Retrieve Store Id
70+
*
71+
* @return mixed
72+
*/
73+
public function getStoreId()
74+
{
75+
return $this->getRequest()->getParam('store');
76+
}
77+
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@
100100
an immediate data-sync for that service.
101101
</comment>
102102
<depends>
103-
<field id="facebook_business_extension/business_extension/installed">1</field>
104103
<field id="facebook_business_extension/business_extension/active">1</field>
105104
<field id="facebook_business_extension/business_extension/onsite">1</field>
106105
</depends>
106+
<field id="manual_data_sync_empty" translate="label" type="note" sortOrder="16" showInDefault="1"
107+
showInWebsite="0" showInStore="1">
108+
<depends>
109+
<field id="facebook_business_extension/business_extension/installed">0</field>
110+
</depends>
111+
<frontend_model>Meta\BusinessExtension\Block\Adminhtml\System\Config\ManualDataSyncEmpty</frontend_model>
112+
</field>
107113
</group>
108114
<group id="testing" translate="label" type="text" sortOrder="200" showInDefault="1"
109115
showInWebsite="0" showInStore="1">
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* @var Meta\BusinessExtension\Block\Adminhtml\System\Config\ManualDataSyncEmpty $block
4+
*/
5+
?>
6+
<div>
7+
<?php if ($block->getStoreId()): ?>
8+
<p>Please visit <b>Facebook &amp; Instagram &gt; Overview</b> to connect your store with Meta.</p>
9+
<?php else: ?>
10+
<p>Please select a store view to manually sync data.</p>
11+
<?php endif; ?>
12+
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
showInWebsite="0" showInStore="1">
1010
<label>Push Products</label>
1111
<depends>
12+
<field id="facebook_business_extension/business_extension/installed">1</field>
1213
<field id="facebook_business_extension/catalog_management/enable_catalog_sync">1</field>
1314
</depends>
1415
<frontend_model>Meta\Catalog\Block\Adminhtml\System\Config\ProductFeed</frontend_model>
@@ -17,6 +18,7 @@
1718
showInWebsite="0" showInStore="1">
1819
<label>Push Categories</label>
1920
<depends>
21+
<field id="facebook_business_extension/business_extension/installed">1</field>
2022
<field id="facebook_business_extension/catalog_management/enable_catalog_sync">1</field>
2123
</depends>
2224
<comment>Upload Product Categories to Meta</comment>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
showInWebsite="0" showInStore="1">
2626
<label>Push Promotions</label>
2727
<frontend_model>Meta\Promotions\Block\Adminhtml\System\Config\PushPromotions</frontend_model>
28+
<depends>
29+
<field id="facebook_business_extension/business_extension/installed">1</field>
30+
<field id="facebook/promotions/enable_promotions_sync">1</field>
31+
</depends>
2832
</field>
2933
</group>
3034
</section>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<label>Pull Orders</label>
1111
<frontend_model>Meta\Sales\Block\Adminhtml\System\Config\PullOrders</frontend_model>
1212
<depends>
13+
<field id="facebook_business_extension/business_extension/installed">1</field>
1314
<field id="facebook_business_extension/orders_sync/active">1</field>
1415
</depends>
1516
<comment>Pull orders awaiting acknowledgement from your Meta Commerce Account</comment>

0 commit comments

Comments
 (0)