Skip to content

Commit 4fc9c2d

Browse files
committed
Merge remote-tracking branch 'magento2/develop' into MPI-BUGFIXES
2 parents 8c4a1a5 + 26630f7 commit 4fc9c2d

File tree

30 files changed

+159
-372
lines changed

30 files changed

+159
-372
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
use Magento\Backend\Block\Widget\Form\Generic;
1717
use Magento\Config\Model\Config\Source\Yesno;
18+
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
1819
use Magento\Eav\Helper\Data;
20+
use Magento\Framework\App\ObjectManager;
1921

2022
class Advanced extends Generic
2123
{
@@ -36,6 +38,11 @@ class Advanced extends Generic
3638
*/
3739
protected $disableScopeChangeList;
3840

41+
/**
42+
* @var PropertyLocker
43+
*/
44+
private $propertyLocker;
45+
3946
/**
4047
* @param \Magento\Backend\Block\Template\Context $context
4148
* @param \Magento\Framework\Registry $registry
@@ -241,6 +248,7 @@ protected function _prepareForm()
241248
$form->getElement('is_global')->setDisabled(1);
242249
}
243250
$this->setForm($form);
251+
$this->getPropertyLocker()->lock($form);
244252
return $this;
245253
}
246254

@@ -264,4 +272,17 @@ private function getAttributeObject()
264272
{
265273
return $this->_coreRegistry->registry('entity_attribute');
266274
}
275+
276+
/**
277+
* Get property locker
278+
*
279+
* @return PropertyLocker
280+
*/
281+
private function getPropertyLocker()
282+
{
283+
if (null === $this->propertyLocker) {
284+
$this->propertyLocker = ObjectManager::getInstance()->get(PropertyLocker::class);
285+
}
286+
return $this->propertyLocker;
287+
}
267288
}

app/code/Magento/Catalog/Model/Product/Attribute/Source/Status.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ public function addValueSortToCollection($collection, $dir = 'asc')
9595
$attributeCode = $this->getAttribute()->getAttributeCode();
9696
$attributeId = $this->getAttribute()->getId();
9797
$attributeTable = $this->getAttribute()->getBackend()->getTable();
98+
$linkField = $this->getAttribute()->getEntity()->getLinkField();
9899

99100
if ($this->getAttribute()->isScopeGlobal()) {
100101
$tableName = $attributeCode . '_t';
101102

102103
$collection->getSelect()->joinLeft(
103104
[$tableName => $attributeTable],
104-
"e.entity_id={$tableName}.entity_id" .
105+
"e.{$linkField}={$tableName}.{$linkField}" .
105106
" AND {$tableName}.attribute_id='{$attributeId}'" .
106107
" AND {$tableName}.store_id='0'",
107108
[]
@@ -114,13 +115,13 @@ public function addValueSortToCollection($collection, $dir = 'asc')
114115

115116
$collection->getSelect()->joinLeft(
116117
[$valueTable1 => $attributeTable],
117-
"e.entity_id={$valueTable1}.entity_id" .
118+
"e.{$linkField}={$valueTable1}.{$linkField}" .
118119
" AND {$valueTable1}.attribute_id='{$attributeId}'" .
119120
" AND {$valueTable1}.store_id='0'",
120121
[]
121122
)->joinLeft(
122123
[$valueTable2 => $attributeTable],
123-
"e.entity_id={$valueTable2}.entity_id" .
124+
"e.{$linkField}={$valueTable2}.{$linkField}" .
124125
" AND {$valueTable2}.attribute_id='{$attributeId}'" .
125126
" AND {$valueTable2}.store_id='{$collection->getStoreId()}'",
126127
[]

app/code/Magento/Catalog/Model/Product/Visibility.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,13 @@ public function addValueSortToCollection($collection, $dir = 'asc')
211211
$attributeCode = $this->getAttribute()->getAttributeCode();
212212
$attributeId = $this->getAttribute()->getId();
213213
$attributeTable = $this->getAttribute()->getBackend()->getTable();
214+
$linkField = $this->getAttribute()->getEntity()->getLinkField();
214215

215216
if ($this->getAttribute()->isScopeGlobal()) {
216217
$tableName = $attributeCode . '_t';
217218
$collection->getSelect()->joinLeft(
218219
[$tableName => $attributeTable],
219-
"e.entity_id={$tableName}.entity_id" .
220+
"e.{$linkField}={$tableName}.{$linkField}" .
220221
" AND {$tableName}.attribute_id='{$attributeId}'" .
221222
" AND {$tableName}.store_id='0'",
222223
[]
@@ -227,13 +228,13 @@ public function addValueSortToCollection($collection, $dir = 'asc')
227228
$valueTable2 = $attributeCode . '_t2';
228229
$collection->getSelect()->joinLeft(
229230
[$valueTable1 => $attributeTable],
230-
"e.entity_id={$valueTable1}.entity_id" .
231+
"e.{$linkField}={$valueTable1}.{$linkField}" .
231232
" AND {$valueTable1}.attribute_id='{$attributeId}'" .
232233
" AND {$valueTable1}.store_id='0'",
233234
[]
234235
)->joinLeft(
235236
[$valueTable2 => $attributeTable],
236-
"e.entity_id={$valueTable2}.entity_id" .
237+
"e.{$linkField}={$valueTable2}.{$linkField}" .
237238
" AND {$valueTable2}.attribute_id='{$attributeId}'" .
238239
" AND {$valueTable2}.store_id='{$collection->getStoreId()}'",
239240
[]

app/code/Magento/Catalog/Setup/CategorySetup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,9 @@ public function getDefaultEntities()
738738
'sort_order' => 9,
739739
'visible' => true,
740740
'group' => 'General',
741+
'is_used_in_grid' => false,
742+
'is_visible_in_grid' => false,
743+
'is_filterable_in_grid' => false,
741744
],
742745
'options_container' => [
743746
'type' => 'varchar',

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab;
77

8+
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
9+
810
class AdvancedTest extends \PHPUnit_Framework_TestCase
911
{
1012
/**
@@ -42,6 +44,11 @@ class AdvancedTest extends \PHPUnit_Framework_TestCase
4244
*/
4345
protected $filesystem;
4446

47+
/**
48+
* @var PropertyLocker|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
protected $propertyLocker;
51+
4552
protected function setUp()
4653
{
4754
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -51,6 +58,7 @@ protected function setUp()
5158
$this->localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface');
5259
$this->eavData = $this->getMock('Magento\Eav\Helper\Data', [], [], '', false);
5360
$this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
61+
$this->propertyLocker = $this->getMock(PropertyLocker::class, [], [], '', false);
5462

5563
$this->block = $objectManager->getObject(
5664
'Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced',
@@ -60,7 +68,8 @@ protected function setUp()
6068
'localeDate' => $this->localeDate,
6169
'yesNo' => $this->yesNo,
6270
'eavData' => $this->eavData,
63-
'filesystem' => $this->filesystem
71+
'filesystem' => $this->filesystem,
72+
'propertyLocker' => $this->propertyLocker,
6473
]
6574
);
6675
}
@@ -93,6 +102,7 @@ public function testToHtml()
93102
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
94103
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
95104
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
105+
$this->propertyLocker->expects($this->once())->method('lock')->with($form);
96106

97107
$this->block->setData(['action' => 'save']);
98108
$this->block->toHtml();

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php

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

99
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
1010

11+
use Magento\Eav\Model\Entity\AbstractEntity;
1112
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1213

1314
class StatusTest extends \PHPUnit_Framework_TestCase
@@ -27,6 +28,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase
2728
/** @var \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\PHPUnit_Framework_MockObject_MockObject */
2829
protected $backendAttributeModel;
2930

31+
/**
32+
* @var AbstractEntity|\PHPUnit_Framework_MockObject_MockObject
33+
*/
34+
protected $entity;
35+
3036
protected function setUp()
3137
{
3238
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -53,6 +59,7 @@ protected function setUp()
5359
'getBackend',
5460
'getId',
5561
'isScopeGlobal',
62+
'getEntity',
5663
],
5764
[],
5865
'',
@@ -78,6 +85,11 @@ protected function setUp()
7885
->will($this->returnSelf());
7986
$this->backendAttributeModel->expects($this->any())->method('getTable')
8087
->will($this->returnValue('table_name'));
88+
89+
$this->entity = $this->getMockBuilder(AbstractEntity::class)
90+
->disableOriginalConstructor()
91+
->setMethods(['getLinkField'])
92+
->getMockForAbstractClass();
8193
}
8294

8395
public function testAddValueSortToCollectionGlobal()
@@ -87,6 +99,9 @@ public function testAddValueSortToCollectionGlobal()
8799
$this->collection->expects($this->once())->method('order')->with('attribute_code_t.value asc')
88100
->will($this->returnSelf());
89101

102+
$this->attributeModel->expects($this->once())->method('getEntity')->willReturn($this->entity);
103+
$this->entity->expects($this->once())->method('getLinkField')->willReturn('entity_id');
104+
90105
$this->status->setAttribute($this->attributeModel);
91106
$this->status->addValueSortToCollection($this->collection);
92107
}
@@ -105,6 +120,9 @@ public function testAddValueSortToCollectionNotGlobal()
105120
$this->collection->expects($this->any())->method('getCheckSql')
106121
->will($this->returnValue('check_sql'));
107122

123+
$this->attributeModel->expects($this->any())->method('getEntity')->willReturn($this->entity);
124+
$this->entity->expects($this->once())->method('getLinkField')->willReturn('entity_id');
125+
108126
$this->status->setAttribute($this->attributeModel);
109127
$this->status->addValueSortToCollection($this->collection);
110128
}

app/code/Magento/Catalog/Ui/DataProvider/Product/AddWebsitesFieldToCollection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class AddWebsitesFieldToCollection implements AddFieldToCollectionInterface
1818
*/
1919
public function addField(Collection $collection, $field, $alias = null)
2020
{
21-
$collection->addWebsiteNamesToResult();
21+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
22+
$collection->addWebsiteNamesToResult();
2223
}
2324
}

app/code/Magento/Catalog/etc/catalog_attributes.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<attribute name="default_sort_by" />
4646
<attribute name="filter_price_range" />
4747
<attribute name="image" />
48-
<attribute name="category_ids" />
4948
<attribute name="media_gallery_content" />
5049
<attribute name="tier_price" />
5150
<attribute name="gift_message_available" />

app/code/Magento/Catalog/etc/eav_attributes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<attribute code="category_ids">
3333
<field code="is_searchable" locked="true" />
3434
<field code="used_for_sort_by" locked="true" />
35+
<field code="is_used_in_grid" locked="true" />
36+
<field code="is_visible_in_grid" locked="true" />
37+
<field code="is_filterable_in_grid" locked="true" />
3538
</attribute>
3639
<attribute code="media_gallery">
3740
<field code="is_searchable" locked="true" />

app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,14 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
155155
$attributeCode = $this->getAttribute()->getAttributeCode();
156156
$attributeId = $this->getAttribute()->getId();
157157
$attributeTable = $this->getAttribute()->getBackend()->getTable();
158+
$linkField = $this->getAttribute()->getEntity()->getLinkField();
158159

159160
if ($this->getAttribute()->isScopeGlobal()) {
160161
$tableName = $attributeCode . '_t';
161162
$collection->getSelect()
162163
->joinLeft(
163164
[$tableName => $attributeTable],
164-
"e.entity_id={$tableName}.entity_id"
165+
"e.{$linkField}={$tableName}.{$linkField}"
165166
. " AND {$tableName}.attribute_id='{$attributeId}'"
166167
. " AND {$tableName}.store_id='0'",
167168
[]
@@ -173,14 +174,14 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
173174
$collection->getSelect()
174175
->joinLeft(
175176
[$valueTable1 => $attributeTable],
176-
"e.entity_id={$valueTable1}.entity_id"
177+
"e.{$linkField}={$valueTable1}.{$linkField}"
177178
. " AND {$valueTable1}.attribute_id='{$attributeId}'"
178179
. " AND {$valueTable1}.store_id='0'",
179180
[]
180181
)
181182
->joinLeft(
182183
[$valueTable2 => $attributeTable],
183-
"e.entity_id={$valueTable2}.entity_id"
184+
"e.{$linkField}={$valueTable2}.{$linkField}"
184185
. " AND {$valueTable2}.attribute_id='{$attributeId}'"
185186
. " AND {$valueTable2}.store_id='{$collection->getStoreId()}'",
186187
[]

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/BooleanTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Source;
1010

11+
use Magento\Eav\Model\Entity\AbstractEntity;
1112
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1213

1314
class BooleanTest extends \PHPUnit_Framework_TestCase
@@ -67,6 +68,13 @@ public function testAddValueSortToCollection(
6768
$attributeMock = $this->getAttributeMock();
6869
$attributeMock->expects($this->any())->method('isScopeGlobal')->will($this->returnValue($isScopeGlobal));
6970

71+
$entity = $this->getMockBuilder(AbstractEntity::class)
72+
->disableOriginalConstructor()
73+
->setMethods(['getLinkField'])
74+
->getMockForAbstractClass();
75+
$entity->expects($this->once())->method('getLinkField')->willReturn('entity_id');
76+
$attributeMock->expects($this->once())->method('getEntity')->willReturn($entity);
77+
7078
$selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false);
7179

7280
$collectionMock = $this->getCollectionMock();
@@ -173,7 +181,7 @@ protected function getCollectionMock()
173181
*/
174182
protected function getAttributeMock()
175183
{
176-
$attributeMockMethods = ['getAttributeCode', 'getId', 'getBackend', 'isScopeGlobal', '__wakeup'];
184+
$attributeMockMethods = ['getAttributeCode', 'getId', 'getBackend', 'isScopeGlobal', '__wakeup' , 'getEntity'];
177185
$attributeMock = $this->getMock(
178186
'\Magento\Eav\Model\Entity\Attribute\AbstractAttribute', $attributeMockMethods, [], '', false
179187
);

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ define([
542542
*/
543543
_OnChange: function ($this, $widget) {
544544
var $parent = $this.parents('.' + $widget.options.classes.attributeClass),
545-
$input = $parent.find('.' + $widget.options.classes.attributeInput);
545+
attributeId = $parent.attr('attribute-id'),
546+
$input = $widget.productForm.find(
547+
'.' + $widget.options.classes.attributeInput + '[name="super_attribute[' + attributeId + ']"]'
548+
);
546549

547550
if ($this.val() > 0) {
548551
$parent.attr('option-selected', $this.val());

dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/Price/AlgorithmBaseTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,12 @@ public function testPricesSegmentation($categoryId, array $entityIds, array $int
6767
['entityMetadata' => $entityMetadata]
6868
);
6969

70-
/** @var \Magento\Framework\Search\Document[] $documents */
70+
/** @var \Magento\Framework\Api\Search\Document[] $documents */
7171
$documents = [];
7272
foreach ($entityIds as $entityId) {
7373
$rawDocument = [
74-
[
75-
'name' => $idKey,
76-
'value' => $entityId,
77-
],
78-
[
79-
'name' => 'score',
80-
'value' => 1,
81-
],
74+
$idKey => $entityId,
75+
'score' => 1,
8276
];
8377
$documents[] = $documentFactory->create($rawDocument);
8478
}

dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function assertProductIds($queryResponse, $expectedIds)
110110
{
111111
$actualIds = [];
112112
foreach ($queryResponse as $document) {
113-
/** @var \Magento\Framework\Search\Document $document */
113+
/** @var \Magento\Framework\Api\Search\Document $document */
114114
$actualIds[] = $document->getId();
115115
}
116116
sort($actualIds);

dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,4 +4223,6 @@
42234223
['Magento\Braintree\Test\Unit\Observer\ProcessBraintreePaymentTest'],
42244224
['Magento\Catalog\Model\Webapi\Product\Option\Type\File\Validator'],
42254225
['Magento\Catalog\Test\Unit\Webapi\Product\Option\Type\File\ValidatorTest'],
4226+
['Magento\Framework\Search\Document', 'Magento\Framework\Api\Search\Document'],
4227+
['Magento\Framework\Search\DocumentField'],
42264228
];

0 commit comments

Comments
 (0)