Skip to content

Commit 300a17c

Browse files
committed
Init module
0 parents  commit 300a17c

File tree

6 files changed

+96
-0
lines changed

6 files changed

+96
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DK\CustomOptionDefaultValue\Plugin\Catalog\UI\Form\Modifier;
6+
7+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions;
8+
use Magento\Ui\Component\Form\Element\DataType\Text;
9+
use Magento\Ui\Component\Form\Element\Checkbox;
10+
use Magento\Ui\Component\Form\Field;
11+
12+
class IsDefaultCustomOption
13+
{
14+
private const FIELD_IS_DEFAULT = 'is_default';
15+
16+
public function afterModifyMeta(CustomOptions $subject, array $meta): array
17+
{
18+
echo "<pre>";
19+
print_r($meta);
20+
die();
21+
22+
$result = array_replace_recursive($meta, [
23+
CustomOptions::GROUP_CUSTOM_OPTIONS_NAME
24+
]);
25+
}
26+
27+
protected function getIsDefaultFieldConfig($sortOrder): array
28+
{
29+
return [
30+
'arguments' => [
31+
'data' => [
32+
'config' => [
33+
'label' => __('Default Value'),
34+
'componentType' => Field::NAME,
35+
'formElement' => Checkbox::NAME,
36+
'dataScope' => static::FIELD_IS_DEFAULT,
37+
'dataType' => Text::NAME,
38+
'sortOrder' => $sortOrder,
39+
'value' => '0',
40+
'valueMap' => [
41+
'true' => '1',
42+
'false' => '0'
43+
],
44+
],
45+
],
46+
],
47+
];
48+
}
49+
}

etc/adminhtml/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions">
5+
<plugin name="dk_custom_option_default_value_option_is_default"
6+
type="DK\CustomOptionDefaultValue\Plugin\Catalog\UI\Form\Modifier\IsDefaultCustomOption"
7+
disabled="false"
8+
/>
9+
</type>
10+
</config>

etc/db_schema.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
3+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
5+
<table name="catalog_product_option_type_value">
6+
<column xsi:type="smallint" name="is_default" padding="5" unsigned="true" nullable="false" identity="false"
7+
default="0" comment="Is Default" />
8+
</table>
9+
</schema>

etc/db_schema_whitelist.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"catalog_product_option_type_value": {
3+
"column": {
4+
"is_default": true
5+
}
6+
}
7+
}

etc/module.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
4+
<module name="DK_CustomOptionDefaultValue" setup_version="1.0.0" >
5+
<sequence>
6+
<module name="Magento_Backend" />
7+
<module name="Magento_Catalog" />
8+
</sequence>
9+
</module>
10+
</config>

registration.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Magento\Framework\Component\ComponentRegistrar;
6+
7+
ComponentRegistrar::register(
8+
ComponentRegistrar::MODULE,
9+
'DK_CustomOptionDefaultValue',
10+
__DIR__
11+
);

0 commit comments

Comments
 (0)