Skip to content

Commit 545b6d3

Browse files
Merge pull request #564 from magento/511_2_content-snapshot-product-admin-page
#511: Content Snapshot on Product Page in Admin Panel (2)
2 parents 88bd82f + 55d1599 commit 545b6d3

File tree

4 files changed

+151
-0
lines changed

4 files changed

+151
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types = 1);
8+
9+
namespace Magento\PageBuilder\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier;
10+
11+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
12+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav as EavModifier;
13+
use Magento\Framework\Stdlib\ArrayManager;
14+
15+
/**
16+
* Data Provider for EAV Attributes on Product Page
17+
*/
18+
class EavPlugin
19+
{
20+
public const META_ATTRIBUTE_CONFIG_PATH = 'arguments/data/config';
21+
22+
/**
23+
* @var ArrayManager
24+
*/
25+
private $arrayManager;
26+
27+
/**
28+
* @param ArrayManager $arrayManager
29+
*/
30+
public function __construct(ArrayManager $arrayManager)
31+
{
32+
$this->arrayManager = $arrayManager;
33+
}
34+
35+
/**
36+
* Setup Attribute Meta
37+
*
38+
* @param EavModifier $subject
39+
* @param array $result
40+
* @param ProductAttributeInterface $attribute
41+
* @param string $groupCode
42+
* @param int $sortOrder
43+
* @return array
44+
*
45+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
46+
*/
47+
public function afterSetupAttributeMeta(
48+
EavModifier $subject,
49+
$result,
50+
ProductAttributeInterface $attribute,
51+
$groupCode,
52+
$sortOrder
53+
) {
54+
$meta = $result;
55+
56+
if ($attribute->getData('is_pagebuilder_enabled')) {
57+
$meta = $this->arrayManager->merge(
58+
static::META_ATTRIBUTE_CONFIG_PATH,
59+
$result,
60+
[
61+
'additionalClasses' => 'admin__field-wide admin__field-page-builder'
62+
]
63+
);
64+
}
65+
66+
return $meta;
67+
}
68+
69+
/**
70+
* Setup Attribute Container Meta
71+
*
72+
* @param EavModifier $subject
73+
* @param array $result
74+
* @param ProductAttributeInterface $attribute
75+
* @return array
76+
*
77+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
78+
*/
79+
public function afterSetupAttributeContainerMeta(
80+
EavModifier $subject,
81+
$result,
82+
ProductAttributeInterface $attribute
83+
) {
84+
$containerMeta = $result;
85+
86+
if ($attribute->getData('is_pagebuilder_enabled')) {
87+
$containerMeta = $this->arrayManager->merge(
88+
static::META_ATTRIBUTE_CONFIG_PATH,
89+
$result,
90+
[
91+
'additionalFieldsetClasses' => [
92+
'admin__field-wide' => true,
93+
'admin__field-page-builder' => true
94+
],
95+
'template' => 'Magento_PageBuilder/form/components/group/group'
96+
]
97+
);
98+
}
99+
100+
return $containerMeta;
101+
}
102+
}

app/code/Magento/PageBuilder/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,7 @@
623623
<type name="Magento\Framework\Filter\Template">
624624
<plugin name="convertBackgroundImages" type="Magento\PageBuilder\Plugin\Filter\TemplatePlugin"/>
625625
</type>
626+
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav">
627+
<plugin name="pagebuilder_product_form_eav" type="Magento\PageBuilder\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier\EavPlugin" sortOrder="20"/>
628+
</type>
626629
</config>

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_config.less

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@
6464
}
6565
}
6666
}
67+
68+
/* Product */
69+
> fieldset.admin__field-page-builder {
70+
.admin__field-label {
71+
text-align: left;
72+
73+
span[data-config-scope] {
74+
&:before {
75+
right: unset;
76+
}
77+
}
78+
}
79+
}
6780
}
6881

6982
.admin__field-wide.admin__field-page-builder {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<fieldset class="admin__field"
8+
visible="visible"
9+
css="Object.assign({_required: required}, $data.additionalFieldsetClasses)"
10+
attr="'data-index': index">
11+
<legend class="admin__field-label" if="showLabel">
12+
<span translate="label" attr="'data-config-scope': $data.scopeLabel"/>
13+
</legend>
14+
15+
<div class="admin__field-control" css="$data.additionalClasses">
16+
<each args="elems">
17+
<if args="visible()" if="!$data.additionalForGroup">
18+
<render args="$parent.fieldTemplate" if="element.input_type != 'checkbox' || element.input_type != 'radio'"/>
19+
<render args="elementTmpl" if="element.input_type == 'checkbox' || element.input_type == 'radio'"/>
20+
</if>
21+
</each>
22+
23+
<each args="getRegion('insideGroup')" render=""/>
24+
25+
<each args="elems" if="validateWholeGroup">
26+
<if args="!$data.additionalForGroup">
27+
<label class="admin__field-error" if="error() && visible()" attr="for: uid" text="error"/>
28+
</if>
29+
</each>
30+
</div>
31+
32+
<each args="getRegion('outsideGroup')" render=""/>
33+
</fieldset>

0 commit comments

Comments
 (0)