Skip to content

Commit 4ebda96

Browse files
author
Hayder Sharhan
committed
Merge remote-tracking branch 'remotes/origin/develop' into for-pr
2 parents 5b82bfc + 9ee50d9 commit 4ebda96

File tree

17 files changed

+220
-120
lines changed

17 files changed

+220
-120
lines changed

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public function execute()
192192
if ($layoutUpdates && is_array($layoutUpdates)) {
193193
foreach ($layoutUpdates as $layoutUpdate) {
194194
$page->addUpdate($layoutUpdate);
195+
$page->addPageLayoutHandles(['layout_update' => md5($layoutUpdate)]);
195196
}
196197
}
197198

app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ protected function setUp()
125125
$this->pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf());
126126

127127
$this->page = $this->getMockBuilder('Magento\Framework\View\Page')
128-
->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'])
128+
->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout', 'addUpdate'])
129129
->disableOriginalConstructor()->getMock();
130130
$this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfig));
131131
$this->page->expects($this->any())->method('addPageLayoutHandles')->will($this->returnSelf());
132132
$this->page->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
133+
$this->page->expects($this->any())->method('addUpdate')->willReturnSelf();
133134

134135
$this->view = $this->getMock('Magento\Framework\App\ViewInterface');
135136
$this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
@@ -192,8 +193,15 @@ public function testApplyCustomLayoutUpdate()
192193

193194
$this->categoryHelper->expects($this->any())->method('canShow')->will($this->returnValue(true));
194195

195-
$settings = $this->getMock('Magento\Framework\DataObject', ['getPageLayout'], [], '', false);
196+
$settings = $this->getMock(
197+
'Magento\Framework\DataObject',
198+
['getPageLayout', 'getLayoutUpdates'],
199+
[],
200+
'',
201+
false
202+
);
196203
$settings->expects($this->atLeastOnce())->method('getPageLayout')->will($this->returnValue($pageLayout));
204+
$settings->expects($this->once())->method('getLayoutUpdates')->willReturn(['update1', 'update2']);
197205

198206
$this->catalogDesign->expects($this->any())->method('getDesignSettings')->will($this->returnValue($settings));
199207

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// @codingStandardsIgnoreFile
88

99
/** @var $block \Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\Options */
10+
11+
$stores = $block->getStoresSortedBySortOrder();
1012
?>
1113
<fieldset class="fieldset">
1214
<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Options (Values of Your Attribute)') ?></span></legend>
@@ -15,14 +17,14 @@
1517
<thead>
1618
<tr id="attribute-options-table">
1719
<th class="col-draggable"></th>
18-
<th class="col-default control-table-actions-th"><?php /* @escapeNotVerified */ echo __('Is Default') ?></th>
20+
<th class="col-default control-table-actions-th"><span><?php /* @escapeNotVerified */ echo __('Is Default') ?></span></th>
1921
<?php
20-
$storelist = $block->getStores();
21-
foreach ($storelist as $_store):
22-
?>
23-
<th><?php /* @escapeNotVerified */ echo __($_store->getName()) ?></th>
22+
foreach ($stores as $_store): ?>
23+
<th<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> class="_required"<?php endif; ?>>
24+
<span><?php /* @escapeNotVerified */ echo __($_store->getName()) ?></span>
25+
</th>
2426
<?php endforeach;
25-
$storetotal = count($storelist) + 3;
27+
$storetotal = count($stores) + 3;
2628
?>
2729
<th class="col-delete">&nbsp;</th>
2830
</tr>
@@ -59,7 +61,7 @@
5961
<td class="col-default control-table-actions-cell">
6062
<input class="input-radio" type="<%- data.intype %>" name="default[]" value="<%- data.id %>" <%- data.checked %><?php if ($block->getReadOnly()):?>disabled="disabled"<?php endif;?>/>
6163
</td>
62-
<?php foreach ($block->getStores() as $_store): ?>
64+
<?php foreach ($stores as $_store): ?>
6365
<td class="col-<%- data.id %>"><input name="option[value][<%- data.id %>][<?php /* @escapeNotVerified */ echo $_store->getId() ?>]" value="<%- data.store<?php /* @escapeNotVerified */ echo $_store->getId() ?> %>" class="input-text<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> required-option<?php endif; ?>" type="text" <?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()):?> disabled="disabled"<?php endif;?>/></td>
6466
<?php endforeach; ?>
6567
<td id="delete_button_container_<%- data.id %>" class="col-delete">

app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function canManageOptionDefaultOnly()
7272
/**
7373
* Retrieve stores collection with default store
7474
*
75-
* @return Collection
75+
* @return array
7676
*/
7777
public function getStores()
7878
{
@@ -82,6 +82,25 @@ public function getStores()
8282
return $this->_getData('stores');
8383
}
8484

85+
/**
86+
* Returns stores sorted by Sort Order
87+
*
88+
* @return array
89+
*/
90+
public function getStoresSortedBySortOrder()
91+
{
92+
$stores = $this->getStores();
93+
if (is_array($stores)) {
94+
usort($stores, function ($storeA, $storeB) {
95+
if ($storeA->getSortOrder() == $storeB->getSortOrder()) {
96+
return $storeA->getId() < $storeB->getId() ? -1 : 1;
97+
}
98+
return ($storeA->getSortOrder() < $storeB->getSortOrder()) ? -1 : 1;
99+
});
100+
}
101+
return $stores;
102+
}
103+
85104
/**
86105
* Retrieve attribute option values if attribute input type select or multiselect
87106
*

app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ public function add($entityType, $attributeCode, $option)
4848
if (!$attribute->usesSource()) {
4949
throw new StateException(__('Attribute %1 doesn\'t work with options', $attributeCode));
5050
}
51-
$optionId = 'new_option';
52-
if ($option->getValue()) {
53-
$this->validateOption($attribute, $option->getValue());
54-
$optionId = $option->getValue();
55-
}
5651

52+
$optionId = $this->getOptionId($option);
5753
$options = [];
5854
$options['value'][$optionId][0] = $option->getLabel();
5955
$options['order'][$optionId] = $option->getSortOrder();
@@ -142,4 +138,13 @@ protected function validateOption($attribute, $optionId)
142138
);
143139
}
144140
}
141+
142+
/**
143+
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
144+
* @return string
145+
*/
146+
private function getOptionId($option)
147+
{
148+
return $option->getValue() ?: 'new_option';
149+
}
145150
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sku,tier_price_website,tier_price_customer_group,tier_price_qty,tier_price
2-
sku123,website1,General,2,10
2+
sku123,base,General,2,10
33
sku124,All Websites [USD],ALL GROUPS,3,15
44
sku123,,,,
55
sku124,,,,

0 commit comments

Comments
 (0)