Skip to content

Commit 2d414e7

Browse files
committed
MC-24930: Admin: Edit product Attribute
1 parent 90a479f commit 2d414e7

File tree

46 files changed

+3014
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3014
-129
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Catalog\Model\Product\Attribute\DataProvider;
9+
10+
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
11+
use Magento\TestFramework\Eav\Model\Attribute\DataProvider\AbstractBaseAttributeData;
12+
use Magento\Store\Model\Store;
13+
use Magento\Catalog\Model\Product\Attribute\Backend\Price as BackendPrice;
14+
15+
/**
16+
* Product attribute data for attribute with input type weee.
17+
*/
18+
class Decimal extends AbstractBaseAttributeData
19+
{
20+
/**
21+
* @inheritdoc
22+
*/
23+
public function __construct()
24+
{
25+
parent::__construct();
26+
$this->defaultAttributePostData['is_filterable'] = '0';
27+
$this->defaultAttributePostData['is_filterable_in_search'] = '0';
28+
$this->defaultAttributePostData['used_for_sort_by'] = '0';
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function getAttributeData(): array
35+
{
36+
$result = parent::getAttributeData();
37+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
38+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
39+
40+
return $result;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function getAttributeDataWithCheckArray(): array
47+
{
48+
$result = parent::getAttributeDataWithCheckArray();
49+
unset($result["{$this->getFrontendInput()}_with_default_value"]);
50+
unset($result["{$this->getFrontendInput()}_without_default_value"]);
51+
52+
return $result;
53+
}
54+
55+
/**
56+
* @inheritdoc
57+
*/
58+
public function getUpdateProvider(): array
59+
{
60+
$frontendInput = $this->getFrontendInput();
61+
return array_replace_recursive(
62+
parent::getUpdateProvider(),
63+
[
64+
"{$frontendInput}_other_attribute_code" => [
65+
'post_data' => [
66+
'attribute_code' => 'text_attribute_update',
67+
],
68+
'expected_data' => [
69+
'attribute_code' => 'decimal_attribute',
70+
],
71+
],
72+
]
73+
);
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
protected function getFrontendInput(): string
80+
{
81+
return 'price';
82+
}
83+
84+
/**
85+
* @inheritdoc
86+
*/
87+
protected function getUpdatePostData(): array
88+
{
89+
return [
90+
'frontend_label' => [
91+
Store::DEFAULT_STORE_ID => 'Decimal Attribute Update',
92+
],
93+
'frontend_input' => 'price',
94+
'is_required' => '1',
95+
'is_unique' => '1',
96+
'is_used_in_grid' => '1',
97+
'is_visible_in_grid' => '1',
98+
'is_filterable_in_grid' => '1',
99+
'is_searchable' => '1',
100+
'search_weight' => '2',
101+
'is_visible_in_advanced_search' => '1',
102+
'is_comparable' => '1',
103+
'is_filterable' => '2',
104+
'is_filterable_in_search' => '1',
105+
'position' => '2',
106+
'is_used_for_promo_rules' => '1',
107+
'is_html_allowed_on_front' => '1',
108+
'is_visible_on_front' => '1',
109+
'used_in_product_listing' => '0',
110+
'used_for_sort_by' => '1',
111+
];
112+
}
113+
114+
/**
115+
* @inheritdoc
116+
*/
117+
protected function getUpdateExpectedData(): array
118+
{
119+
$updatePostData = $this->getUpdatePostData();
120+
return array_merge(
121+
$updatePostData,
122+
[
123+
'frontend_label' => 'Decimal Attribute Update',
124+
'attribute_code' => 'decimal_attribute',
125+
'is_global' => ScopedAttributeInterface::SCOPE_GLOBAL,
126+
'default_value' => null,
127+
'frontend_class' => null,
128+
'is_user_defined' => '1',
129+
'backend_type' => 'decimal',
130+
'backend_model' => BackendPrice::class,
131+
]
132+
);
133+
}
134+
}

dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Attribute/DataProvider/MediaImage.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Magento\TestFramework\Catalog\Model\Product\Attribute\DataProvider;
99

10+
use Magento\Catalog\Model\Product\Attribute\Frontend\Image;
11+
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
12+
use Magento\Store\Model\Store;
1013
use Magento\TestFramework\Eav\Model\Attribute\DataProvider\AbstractBaseAttributeData;
1114

1215
/**
@@ -47,11 +50,83 @@ public function getAttributeDataWithCheckArray(): array
4750
return $result;
4851
}
4952

53+
/**
54+
* @inheritdoc
55+
*/
56+
public function getUpdateProvider(): array
57+
{
58+
$frontendInput = $this->getFrontendInput();
59+
return array_replace_recursive(
60+
parent::getUpdateProvider(),
61+
[
62+
"{$frontendInput}_other_attribute_code" => [
63+
'post_data' => [
64+
'attribute_code' => 'text_attribute_update',
65+
],
66+
'expected_data' => [
67+
'attribute_code' => 'image_attribute',
68+
],
69+
],
70+
]
71+
);
72+
}
73+
5074
/**
5175
* @inheritdoc
5276
*/
5377
protected function getFrontendInput(): string
5478
{
5579
return 'media_image';
5680
}
81+
82+
/**
83+
* @inheritdoc
84+
*/
85+
protected function getUpdatePostData(): array
86+
{
87+
return [
88+
'frontend_label' => [
89+
Store::DEFAULT_STORE_ID => 'Decimal Attribute Update',
90+
],
91+
'frontend_input' => 'media_image',
92+
'is_global' => ScopedAttributeInterface::SCOPE_WEBSITE,
93+
'is_used_in_grid' => '1',
94+
'is_visible_in_grid' => '1',
95+
'is_filterable_in_grid' => '1',
96+
];
97+
}
98+
99+
/**
100+
* @inheritdoc
101+
*/
102+
protected function getUpdateExpectedData(): array
103+
{
104+
$updatePostData = $this->getUpdatePostData();
105+
return array_merge(
106+
$updatePostData,
107+
[
108+
'frontend_label' => 'Decimal Attribute Update',
109+
'is_required' => '0',
110+
'attribute_code' => 'image_attribute',
111+
'default_value' => null,
112+
'is_unique' => '0',
113+
'frontend_class' => null,
114+
'is_searchable' => '0',
115+
'search_weight' => '1',
116+
'is_visible_in_advanced_search' => '0',
117+
'is_comparable' => '0',
118+
'is_filterable' => '0',
119+
'is_filterable_in_search' => '0',
120+
'position' => '0',
121+
'is_used_for_promo_rules' => '0',
122+
'is_html_allowed_on_front' => '1',
123+
'is_visible_on_front' => '0',
124+
'used_in_product_listing' => '1',
125+
'used_for_sort_by' => '0',
126+
'is_user_defined' => '1',
127+
'backend_type' => 'varchar',
128+
'frontend_model' => Image::class,
129+
]
130+
);
131+
}
57132
}

dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Attribute/DataProvider/Price.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

dev/tests/integration/framework/Magento/TestFramework/Eav/Model/Attribute/DataProvider/AbstractAttributeDataWithOptions.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\TestFramework\Eav\Model\Attribute\DataProvider;
99

10+
use Magento\Store\Model\Store;
11+
1012
/**
1113
* Base POST data for create attribute with options.
1214
*/
@@ -72,6 +74,67 @@ public function getAttributeDataWithCheckArray(): array
7274
return $result;
7375
}
7476

77+
/**
78+
* Return product attribute data set for update attribute options.
79+
*
80+
* @return array
81+
*/
82+
public function getUpdateOptionsProvider(): array
83+
{
84+
$frontendInput = $this->getFrontendInput();
85+
return [
86+
"{$frontendInput}_update_options" => [
87+
'post_data' => [
88+
'options_array' => [
89+
'option_1' => [
90+
'order' => '5',
91+
'value' => [
92+
Store::DEFAULT_STORE_ID => 'Option 1 Admin',
93+
'default' => 'Option 1 Store 1',
94+
'fixture_second_store' => 'Option 1 Store 2',
95+
'fixture_third_store' => 'Option 1 Store 3',
96+
],
97+
'delete' => '',
98+
],
99+
'option_2' => [
100+
'order' => '6',
101+
'value' => [
102+
Store::DEFAULT_STORE_ID => 'Option 2 Admin',
103+
'default' => 'Option 2 Store 1',
104+
'fixture_second_store' => 'Option 2 Store 2',
105+
'fixture_third_store' => 'Option 2 Store 3',
106+
],
107+
'delete' => '',
108+
'default' => 1,
109+
],
110+
],
111+
],
112+
],
113+
"{$frontendInput}_delete_options" => [
114+
'post_data' => [
115+
'options_array' => [
116+
'option_1' => [
117+
'value' => [],
118+
'delete' => '',
119+
],
120+
'option_2' => [
121+
'value' => [],
122+
'delete' => '1',
123+
],
124+
'option_3' => [
125+
'value' => [],
126+
'delete' => '',
127+
],
128+
'option_4' => [
129+
'value' => [],
130+
'delete' => '1',
131+
],
132+
],
133+
],
134+
],
135+
];
136+
}
137+
75138
/**
76139
* Return attribute options data.
77140
*

0 commit comments

Comments
 (0)