Skip to content

Commit 0112e42

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into troll_bugfix
2 parents 6d3e655 + 6619bdf commit 0112e42

File tree

30 files changed

+760
-202
lines changed

30 files changed

+760
-202
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
281281
if (!empty($columnValueNames)) {
282282
$select->joinLeft(
283283
$temporaryValueTableName,
284-
sprintf('e.%1$s = %2$s.%1$s', $linkField, $temporaryTableName),
284+
sprintf('e.%1$s = %2$s.%1$s', $linkField, $temporaryValueTableName),
285285
$columnValueNames
286286
);
287287
$allColumns = array_merge($allColumns, $columnValueNames);

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,44 +107,42 @@ protected function setUp()
107107

108108
public function testBuild()
109109
{
110-
list($storeId, $changedIds, $valueFieldSuffix, $tableDropSuffix, $fillTmpTables) = [1, [], '', '', true];
110+
$storeId = 1;
111+
$changedIds = [];
112+
$valueFieldSuffix = '_value';
113+
$tableDropSuffix = '';
114+
$fillTmpTables = true;
111115
$tableName = 'catalog_product_entity';
112116
$attributeTable = 'catalog_product_entity_int';
113117
$temporaryTableName = 'catalog_product_entity_int_tmp_indexer';
114-
$temporaryValueTableName = 'catalog_product_entity_int_tmp_indexer';
118+
$temporaryValueTableName = 'catalog_product_entity_int_tmp_indexer_value';
115119
$linkField = 'entity_id';
116120
$statusId = 22;
121+
$eavCustomField = 'space_weight';
122+
$eavCustomValueField = $eavCustomField . $valueFieldSuffix;
117123
$this->flatIndexerMock->expects($this->once())->method('getAttributes')->willReturn([]);
118124
$this->flatIndexerMock->expects($this->exactly(3))->method('getFlatColumns')
119-
->willReturnOnConsecutiveCalls(
120-
[],
121-
[$linkField => []],
122-
[$linkField => []]
123-
);
125+
->willReturnOnConsecutiveCalls([], [$eavCustomValueField => []], [$eavCustomValueField => []]);
124126
$this->flatIndexerMock->expects($this->once())->method('getFlatIndexes')->willReturn([]);
125127
$statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
126128
->disableOriginalConstructor()
127129
->getMock();
130+
$eavCustomAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
131+
->disableOriginalConstructor()
132+
->getMock();
128133
$this->flatIndexerMock->expects($this->once())->method('getTablesStructure')
129134
->willReturn(
130135
[
131-
'catalog_product_entity' => [
132-
$linkField => $statusAttributeMock
133-
],
136+
'catalog_product_entity' => [$linkField => $statusAttributeMock],
134137
'catalog_product_entity_int' => [
135-
$linkField => $statusAttributeMock
138+
$linkField => $statusAttributeMock,
139+
$eavCustomField => $eavCustomAttributeMock
136140
]
137141
]
138142
);
139143
$this->flatIndexerMock->expects($this->atLeastOnce())->method('getTable')
140-
->withConsecutive(
141-
[$tableName],
142-
['catalog_product_website']
143-
)
144-
->willReturnOnConsecutiveCalls(
145-
$tableName,
146-
'catalog_product_website'
147-
);
144+
->withConsecutive([$tableName], ['catalog_product_website'])
145+
->willReturnOnConsecutiveCalls($tableName, 'catalog_product_website');
148146
$this->flatIndexerMock->expects($this->once())->method('getAttribute')
149147
->with('status')
150148
->willReturn($statusAttributeMock);
@@ -155,6 +153,9 @@ public function testBuild()
155153
$statusAttributeMock->expects($this->atLeastOnce())->method('getBackend')->willReturn(
156154
$backendMock
157155
);
156+
$eavCustomAttributeMock->expects($this->atLeastOnce())->method('getBackend')->willReturn(
157+
$backendMock
158+
);
158159
$statusAttributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($statusId);
159160
$tableMock = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)
160161
->disableOriginalConstructor()
@@ -185,12 +186,12 @@ public function testBuild()
185186
[
186187
$temporaryTableName,
187188
"e.{$linkField} = {$temporaryTableName}.{$linkField}",
188-
[$linkField]
189+
[$linkField, $eavCustomField]
189190
],
190191
[
191192
$temporaryValueTableName,
192-
"e.{$linkField} = " . $temporaryValueTableName . ".{$linkField}",
193-
[$linkField]
193+
"e.{$linkField} = {$temporaryValueTableName}.{$linkField}",
194+
[$eavCustomValueField]
194195
]
195196
)->willReturnSelf();
196197
$this->metadataPoolMock->expects($this->atLeastOnce())->method('getMetadata')->with(ProductInterface::class)

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ protected function createModel()
2424

2525
public function testModifyData()
2626
{
27-
$this->assertSame($this->getSampleData(), $this->getModel()->modifyData($this->getSampleData()));
27+
$this->productMock->expects($this->once())->method('getId')->willReturn(2051);
28+
$actualResult = $this->getModel()->modifyData($this->getSampleData());
29+
$this->assertSame("", $actualResult[2051]['product']['media_gallery']['images'][0]['label']);
2830
}
2931

3032
public function testModifyMeta()
@@ -40,4 +42,24 @@ public function testModifyMeta()
4042

4143
$this->assertSame([], $this->getModel()->modifyMeta($meta));
4244
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
protected function getSampleData()
50+
{
51+
return [
52+
2051 => [
53+
'product' => [
54+
'media_gallery' => [
55+
'images' => [
56+
[
57+
'label' => null
58+
]
59+
]
60+
]
61+
]
62+
]
63+
];
64+
}
4365
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Images.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ public function modifyMeta(array $meta)
5151
*/
5252
public function modifyData(array $data)
5353
{
54+
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
55+
$product = $this->locator->getProduct();
56+
$modelId = $product->getId();
57+
if (
58+
isset($data[$modelId][self::DATA_SOURCE_DEFAULT]['media_gallery'])
59+
&& !empty($data[$modelId][self::DATA_SOURCE_DEFAULT]['media_gallery'])
60+
&& !empty($data[$modelId][self::DATA_SOURCE_DEFAULT]['media_gallery']['images'])
61+
) {
62+
foreach ($data[$modelId][self::DATA_SOURCE_DEFAULT]['media_gallery']['images'] as $index => $image) {
63+
if (!isset($image['label'])) {
64+
$data[$modelId][self::DATA_SOURCE_DEFAULT]['media_gallery']['images'][$index]['label'] = "";
65+
}
66+
}
67+
};
68+
5469
return $data;
5570
}
5671
}

app/code/Magento/CatalogInventory/etc/events.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
<event name="sales_order_item_cancel">
3434
<observer name="inventory" instance="Magento\CatalogInventory\Observer\CancelOrderItemObserver"/>
3535
</event>
36-
<event name="sales_order_creditmemo_save_after">
37-
<observer name="inventory" instance="Magento\CatalogInventory\Observer\RefundOrderInventoryObserver"/>
38-
</event>
3936
<event name="catalog_product_save_after">
4037
<observer name="inventory" instance="Magento\CatalogInventory\Observer\SaveInventoryDataObserver"/>
4138
</event>

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
define([
88
'jquery',
99
'mage/template',
10+
'underscore',
1011
'jquery/ui',
1112
'mage/validation'
12-
], function ($, mageTemplate) {
13+
], function ($, mageTemplate, _) {
1314
'use strict';
1415

1516
$.widget('mage.regionUpdater', {
@@ -124,6 +125,8 @@ define([
124125
* @private
125126
*/
126127
_clearError: function () {
128+
var args = ['clearError', this.options.regionListId, this.options.regionInputId, this.options.postcodeId];
129+
127130
if (this.options.clearError && typeof this.options.clearError === 'function') {
128131
this.options.clearError.call(this);
129132
} else {
@@ -133,8 +136,8 @@ define([
133136

134137
this.options.form = $(this.options.form);
135138

136-
this.options.form && this.options.form.data('validator') && this.options.form.validation('clearError',
137-
this.options.regionListId, this.options.regionInputId, this.options.postcodeId);
139+
this.options.form && this.options.form.data('validator') &&
140+
this.options.form.validation.apply(this.options.form, _.compact(args));
138141

139142
// Clean up errors on region & zip fix
140143
$(this.options.regionInputId).removeClass('mage-error').parent().find('[generated]').remove();

app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ public function load()
217217
foreach ($creditmemo->getAllItems() as $creditmemoItem) {
218218
$orderItem = $creditmemoItem->getOrderItem();
219219
$parentId = $orderItem->getParentItemId();
220-
if (isset($backToStock[$orderItem->getId()])) {
220+
if ($parentId && isset($backToStock[$parentId]) && $backToStock[$parentId]) {
221221
$creditmemoItem->setBackToStock(true);
222-
} elseif ($orderItem->getParentItem() && isset($backToStock[$parentId]) && $backToStock[$parentId]) {
222+
} elseif (isset($backToStock[$orderItem->getId()])) {
223223
$creditmemoItem->setBackToStock(true);
224224
} elseif (empty($savedData)) {
225225
$creditmemoItem->setBackToStock(

app/code/Magento/Sales/Model/Order/CreditmemoFactory.php

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Sales\Model\Order;
87

98
/**
@@ -23,6 +22,11 @@ class CreditmemoFactory
2322
*/
2423
protected $taxConfig;
2524

25+
/**
26+
* @var \Magento\Framework\Unserialize\Unserialize
27+
*/
28+
protected $unserialize;
29+
2630
/**
2731
* Factory constructor
2832
*
@@ -57,7 +61,12 @@ public function createByOrder(\Magento\Sales\Model\Order $order, array $data = [
5761

5862
$item = $this->convertor->itemToCreditmemoItem($orderItem);
5963
if ($orderItem->isDummy()) {
60-
$qty = 1;
64+
if (isset($data['qtys'][$orderItem->getParentItemId()])) {
65+
$parentQty = $data['qtys'][$orderItem->getParentItemId()];
66+
} else {
67+
$parentQty = $orderItem->getParentItem() ? $orderItem->getParentItem()->getQtyToRefund() : 1;
68+
}
69+
$qty = $this->calculateProductOptions($orderItem, $parentQty);
6170
$orderItem->setLockedDoShip(true);
6271
} else {
6372
if (isset($qtys[$orderItem->getId()])) {
@@ -132,7 +141,12 @@ public function createByInvoice(\Magento\Sales\Model\Order\Invoice $invoice, arr
132141

133142
$item = $this->convertor->itemToCreditmemoItem($orderItem);
134143
if ($orderItem->isDummy()) {
135-
$qty = 1;
144+
if (isset($data['qtys'][$orderItem->getParentItemId()])) {
145+
$parentQty = $data['qtys'][$orderItem->getParentItemId()];
146+
} else {
147+
$parentQty = $orderItem->getParentItem() ? $orderItem->getParentItem()->getQtyToRefund() : 1;
148+
}
149+
$qty = $this->calculateProductOptions($orderItem, $parentQty);
136150
} else {
137151
if (isset($qtys[$orderItem->getId()])) {
138152
$qty = (double)$qtys[$orderItem->getId()];
@@ -245,4 +259,38 @@ protected function initData($creditmemo, $data)
245259
$creditmemo->setAdjustmentNegative($data['adjustment_negative']);
246260
}
247261
}
262+
263+
/**
264+
* @param \Magento\Sales\Api\Data\OrderItemInterface $orderItem
265+
* @param array $qtys
266+
* @return int
267+
*/
268+
private function calculateProductOptions(\Magento\Sales\Api\Data\OrderItemInterface $orderItem, $parentQty)
269+
{
270+
$qty = $parentQty;
271+
$productOptions = $orderItem->getProductOptions();
272+
if (isset($productOptions['bundle_selection_attributes'])) {
273+
$bundleSelectionAttributes = $this->getUnserialize()
274+
->unserialize($productOptions['bundle_selection_attributes']);
275+
if ($bundleSelectionAttributes) {
276+
$qty = $bundleSelectionAttributes['qty'] * $parentQty;
277+
}
278+
}
279+
return $qty;
280+
}
281+
282+
/**
283+
* Get Unserialize
284+
*
285+
* @return \Magento\Framework\Unserialize\Unserialize
286+
* @deprecated
287+
*/
288+
private function getUnserialize()
289+
{
290+
if (!$this->unserialize) {
291+
$this->unserialize = \Magento\Framework\App\ObjectManager::getInstance()
292+
->get(\Magento\Framework\Unserialize\Unserialize::class);
293+
}
294+
return $this->unserialize;
295+
}
248296
}

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<referenceBlock name="page.title">
1818
<action method="setTitleId">
19-
<argument translate="true" name="id" xsi:type="string">order-header</argument>
19+
<argument translate="false" name="id" xsi:type="string">order-header</argument>
2020
</action>
2121
</referenceBlock>
2222
<referenceContainer name="after.body.start">

app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@
6666
<?php endif; ?>
6767

6868
<?php if ($block->canDisplayPrice()): ?>
69-
<td class="col-price"><?php /* @noEscape */ echo $block->getItemPrice($_item) ?></td>
69+
<td class="col-price">
70+
<?php if ($block->getDataId() == 'cart'): ?>
71+
<?php /* @noEscape */ echo $block->getItemPrice($_item->getProduct()) ?>
72+
<?php else: ?>
73+
<?php /* @noEscape */ echo $block->getItemPrice($_item) ?>
74+
<?php endif; ?>
75+
</td>
7076
<?php endif; ?>
7177

7278
<?php if ($block->canRemoveItems()): ?>

0 commit comments

Comments
 (0)