Skip to content

Commit 7edd8d0

Browse files
author
Klymenko, Volodymyr(vklymenko)
committed
Merge pull request #401 from magento-dragons/epam-PR-sprint-4
[Epam - Swatches] Merge pull requests (EE: #8, CE: #16)
2 parents 41156cc + f2a127a commit 7edd8d0

31 files changed

+663
-92
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ protected function _prepareForm()
7070
}
7171
$this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields);
7272

73+
$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
74+
7375
$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
7476
$frontendInputElm->setValues($frontendInputValues);
7577

app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,24 @@ class SuggestedAttributeList
1414
*
1515
* @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory
1616
*/
17-
protected $attributeCollectionFactory;
18-
17+
protected $_attributeColFactory;
1918
/**
2019
* Catalog resource helper
2120
*
2221
* @var \Magento\Catalog\Model\Resource\Helper
2322
*/
24-
protected $resourceHelper;
25-
26-
/**
27-
* Application Event Dispatcher
28-
*
29-
* @var \Magento\Framework\Event\ManagerInterface
30-
*/
31-
protected $eventManager;
32-
33-
/**
34-
* Object Factory
35-
*
36-
* @var \Magento\Framework\ObjectFactory
37-
*/
38-
protected $objectFactory;
39-
23+
protected $_resourceHelper;
4024
/**
41-
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
25+
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory
4226
* @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
43-
* @param \Magento\Framework\Event\ManagerInterface $eventManager
44-
* @param \Magento\Framework\ObjectFactory $objectFactory
4527
*/
4628
public function __construct(
47-
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory,
48-
\Magento\Catalog\Model\Resource\Helper $resourceHelper,
49-
\Magento\Framework\Event\ManagerInterface $eventManager,
50-
\Magento\Framework\ObjectFactory $objectFactory
29+
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory,
30+
\Magento\Catalog\Model\Resource\Helper $resourceHelper
5131
) {
52-
$this->attributeCollectionFactory = $attributeCollectionFactory;
53-
$this->resourceHelper = $resourceHelper;
54-
$this->objectFactory = $objectFactory;
55-
$this->eventManager = $eventManager;
32+
$this->_attributeColFactory = $attributeColFactory;
33+
$this->_resourceHelper = $resourceHelper;
5634
}
57-
5835
/**
5936
* Retrieve list of attributes with admin store label containing $labelPart
6037
*
@@ -63,14 +40,12 @@ public function __construct(
6340
*/
6441
public function getSuggestedAttributes($labelPart)
6542
{
66-
$escapedLabelPart = $this->resourceHelper->addLikeEscape($labelPart, ['position' => 'any']);
67-
$availableFrontendTypes = $this->getAvailableFrontendTypes();
68-
43+
$escapedLabelPart = $this->_resourceHelper->addLikeEscape($labelPart, ['position' => 'any']);
6944
/** @var $collection \Magento\Catalog\Model\Resource\Product\Attribute\Collection */
70-
$collection = $this->attributeCollectionFactory->create();
45+
$collection = $this->_attributeColFactory->create();
7146
$collection->addFieldToFilter(
72-
'main_table.frontend_input',
73-
['in' => $availableFrontendTypes->getData('values')]
47+
'frontend_input',
48+
'select'
7449
)->addFieldToFilter(
7550
'frontend_label',
7651
['like' => $escapedLabelPart]
@@ -81,7 +56,6 @@ public function getSuggestedAttributes($labelPart)
8156
'is_global',
8257
\Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL
8358
);
84-
8559
$result = [];
8660
$types = [
8761
\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
@@ -101,22 +75,4 @@ public function getSuggestedAttributes($labelPart)
10175
}
10276
return $result;
10377
}
104-
105-
/**
106-
* @return \Magento\Framework\Object
107-
*/
108-
private function getAvailableFrontendTypes()
109-
{
110-
$availableFrontendTypes = $this->objectFactory->create();
111-
$availableFrontendTypes->setData(
112-
[
113-
'values' => ['select']
114-
]
115-
);
116-
$this->eventManager->dispatch(
117-
'product_suggested_attribute_frontend_type_init_after',
118-
['types_dto' => $availableFrontendTypes]
119-
);
120-
return $availableFrontendTypes;
121-
}
12278
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
protected $attributeFactoryMock;
2222

23-
/**
24-
* @var \PHPUnit_Framework_MockObject_MockObject
25-
*/
26-
protected $eventManagerMock;
27-
28-
/**
29-
* @var \PHPUnit_Framework_MockObject_MockObject
30-
*/
31-
protected $objectFactoryMock;
32-
3323
/**
3424
* @var \PHPUnit_Framework_MockObject_MockObject
3525
*/
@@ -63,20 +53,6 @@ protected function setUp()
6353
'',
6454
false
6555
);
66-
$this->eventManagerMock = $this->getMock(
67-
'\Magento\Framework\Event\ManagerInterface',
68-
[],
69-
[],
70-
'',
71-
false
72-
);
73-
$this->objectFactoryMock = $this->getMock(
74-
'\Magento\Framework\ObjectFactory',
75-
['create'],
76-
[],
77-
'',
78-
false
79-
);
8056
$this->collectionMock = $this->getMock(
8157
'Magento\Catalog\Model\Resource\Product\Attribute\Collection',
8258
[],
@@ -102,7 +78,7 @@ protected function setUp()
10278
$this->returnValue($this->collectionMock)
10379
);
10480
$valueMap = [
105-
['main_table.frontend_input', ['in' => 123 ], $this->collectionMock],
81+
['frontend_input', 'select', $this->collectionMock],
10682
['frontend_label', ['like' => $this->labelPart], $this->collectionMock],
10783
['is_user_defined', 1, $this->collectionMock],
10884
['is_global', \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL, $this->collectionMock],
@@ -131,19 +107,12 @@ protected function setUp()
131107
);
132108
$this->suggestedListModel = new \Magento\ConfigurableProduct\Model\SuggestedAttributeList(
133109
$this->attributeFactoryMock,
134-
$this->resourceHelperMock,
135-
$this->eventManagerMock,
136-
$this->objectFactoryMock
110+
$this->resourceHelperMock
137111
);
138112
}
139113

140114
public function testGetSuggestedAttributesIfTheyApplicable()
141115
{
142-
$object = $this->getMock('\Magento\Framework\Object', [], [], '', false);
143-
$object->expects($this->once())->method('setData');
144-
$object->expects($this->once())->method('getData')->willReturn(123);
145-
$this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object);
146-
147116
$source = $this->getMock(
148117
'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource',
149118
[],
@@ -163,10 +132,6 @@ public function testGetSuggestedAttributesIfTheyApplicable()
163132

164133
public function testGetSuggestedAttributesIfTheyNotApplicable()
165134
{
166-
$object = $this->getMock('\Magento\Framework\Object', [], [], '', false);
167-
$object->expects($this->once())->method('setData');
168-
$object->expects($this->once())->method('getData')->willReturn(123);
169-
$this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object);
170135
$this->attributeMock->expects($this->any())->method('getApplyTo')->will($this->returnValue(['simple']));
171136
$this->attributeMock->expects($this->never())->method('getId');
172137
$this->attributeMock->expects($this->never())->method('getFrontendLabel');
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
.colorpicker {
2+
width: 356px;
3+
height: 176px;
4+
overflow: hidden;
5+
position: absolute;
6+
background: url(../images/colorpicker_background.png);
7+
font-family: Arial, Helvetica, sans-serif;
8+
display: none;
9+
}
10+
.colorpicker_color {
11+
width: 150px;
12+
height: 150px;
13+
left: 14px;
14+
top: 13px;
15+
position: absolute;
16+
background: #f00;
17+
overflow: hidden;
18+
cursor: crosshair;
19+
}
20+
.colorpicker_color div {
21+
position: absolute;
22+
top: 0;
23+
left: 0;
24+
width: 150px;
25+
height: 150px;
26+
background: url(../images/colorpicker_overlay.png);
27+
}
28+
.colorpicker_color div div {
29+
position: absolute;
30+
top: 0;
31+
left: 0;
32+
width: 11px;
33+
height: 11px;
34+
overflow: hidden;
35+
background: url(../images/colorpicker_select.gif);
36+
margin: -5px 0 0 -5px;
37+
}
38+
.colorpicker_hue {
39+
position: absolute;
40+
top: 13px;
41+
left: 171px;
42+
width: 35px;
43+
height: 150px;
44+
cursor: n-resize;
45+
}
46+
.colorpicker_hue div {
47+
position: absolute;
48+
width: 35px;
49+
height: 9px;
50+
overflow: hidden;
51+
background: url(../images/colorpicker_indic.gif) left top;
52+
margin: -4px 0 0 0;
53+
left: 0px;
54+
}
55+
.colorpicker_new_color {
56+
position: absolute;
57+
width: 60px;
58+
height: 30px;
59+
left: 213px;
60+
top: 13px;
61+
background: #f00;
62+
}
63+
.colorpicker_current_color {
64+
position: absolute;
65+
width: 60px;
66+
height: 30px;
67+
left: 283px;
68+
top: 13px;
69+
background: #f00;
70+
}
71+
.colorpicker input {
72+
background-color: transparent;
73+
border: 1px solid transparent;
74+
position: absolute;
75+
font-size: 10px;
76+
font-family: Arial, Helvetica, sans-serif;
77+
color: #898989;
78+
top: 4px;
79+
right: 11px;
80+
text-align: right;
81+
margin: 0;
82+
padding: 0;
83+
height: 11px;
84+
}
85+
.colorpicker_hex {
86+
position: absolute;
87+
width: 72px;
88+
height: 22px;
89+
background: url(../images/colorpicker_hex.png) top;
90+
left: 212px;
91+
top: 142px;
92+
}
93+
.colorpicker_hex input {
94+
right: 6px;
95+
}
96+
.colorpicker_field {
97+
height: 22px;
98+
width: 62px;
99+
background-position: top;
100+
position: absolute;
101+
}
102+
.colorpicker_field span {
103+
position: absolute;
104+
width: 12px;
105+
height: 22px;
106+
overflow: hidden;
107+
top: 0;
108+
right: 0;
109+
cursor: n-resize;
110+
}
111+
.colorpicker_rgb_r {
112+
background-image: url(../images/colorpicker_rgb_r.png);
113+
top: 52px;
114+
left: 212px;
115+
}
116+
.colorpicker_rgb_g {
117+
background-image: url(../images/colorpicker_rgb_g.png);
118+
top: 82px;
119+
left: 212px;
120+
}
121+
.colorpicker_rgb_b {
122+
background-image: url(../images/colorpicker_rgb_b.png);
123+
top: 112px;
124+
left: 212px;
125+
}
126+
.colorpicker_hsb_h {
127+
background-image: url(../images/colorpicker_hsb_h.png);
128+
top: 52px;
129+
left: 282px;
130+
}
131+
.colorpicker_hsb_s {
132+
background-image: url(../images/colorpicker_hsb_s.png);
133+
top: 82px;
134+
left: 282px;
135+
}
136+
.colorpicker_hsb_b {
137+
background-image: url(../images/colorpicker_hsb_b.png);
138+
top: 112px;
139+
left: 282px;
140+
}
141+
.colorpicker_submit {
142+
position: absolute;
143+
width: 22px;
144+
height: 22px;
145+
background: url(../images/colorpicker_submit.png) top;
146+
left: 322px;
147+
top: 142px;
148+
overflow: hidden;
149+
}
150+
.colorpicker_focus {
151+
background-position: center;
152+
}
153+
.colorpicker_hex.colorpicker_focus {
154+
background-position: bottom;
155+
}
156+
.colorpicker_submit.colorpicker_focus {
157+
background-position: bottom;
158+
}
159+
.colorpicker_slider {
160+
background-position: bottom;
161+
}
49 Bytes
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)