Skip to content

Commit 524b607

Browse files
committed
Merge remote-tracking branch 'origin/develop' into NORD-PR
2 parents edc0a00 + b56df96 commit 524b607

File tree

99 files changed

+2657
-306
lines changed

Some content is hidden

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

99 files changed

+2657
-306
lines changed

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ define([
295295
case 'hidden':
296296
optionHash = 'bundle-option-' + optionName + '##' + optionValue;
297297
optionQty = optionConfig[optionValue].qty || 0;
298+
canQtyCustomize = optionConfig[optionValue].customQty === '1';
299+
qtyField = element.data('qtyField');
300+
qtyField.data('option', element);
301+
toggleQtyField(qtyField, optionQty, optionId, optionValue, canQtyCustomize);
298302
tempChanges = utils.deepClone(optionConfig[optionValue].prices);
299303
tempChanges = applyTierPrice(tempChanges, optionQty, optionConfig);
300304
tempChanges = applyQty(tempChanges, optionQty);

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function __construct(\Magento\Catalog\Block\Product\Context $context, arr
124124
*/
125125
public function getAddToCartUrl($product, $additional = [])
126126
{
127-
if ($product->getTypeInstance()->hasRequiredOptions($product)) {
127+
if (!$product->getTypeInstance()->isPossibleBuyFromList($product)) {
128128
if (!isset($additional['_escape'])) {
129129
$additional['_escape'] = true;
130130
}

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/Model/Product/Type/AbstractType.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,4 +1092,15 @@ public function getAssociatedProducts($product)
10921092
{
10931093
return [];
10941094
}
1095+
1096+
/**
1097+
* Check if product can be potentially buyed from the category page or some other list
1098+
*
1099+
* @param \Magento\Catalog\Model\Product $product
1100+
* @return bool
1101+
*/
1102+
public function isPossibleBuyFromList($product)
1103+
{
1104+
return !$this->hasRequiredOptions($product);
1105+
}
10951106
}

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ public function testGetAddToCartPostParams()
154154
];
155155

156156
$this->typeInstanceMock->expects($this->once())
157-
->method('hasRequiredOptions')
157+
->method('isPossibleBuyFromList')
158158
->with($this->equalTo($this->productMock))
159-
->will($this->returnValue(false));
159+
->will($this->returnValue(true));
160160
$this->cartHelperMock->expects($this->any())
161161
->method('getAddUrl')
162162
->with($this->equalTo($this->productMock), $this->equalTo([]))

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/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ define([
8484
}
8585

8686
if (res.backUrl) {
87+
var eventData = {
88+
'form': form,
89+
'redirectParameters': []
90+
}
91+
// trigger global event, so other modules will be able add parameters to redirect url
92+
$('body').trigger('catalogCategoryAddToCartRedirect', eventData);
93+
if (eventData.redirectParameters.length > 0) {
94+
var parameters = res.backUrl.split('#');
95+
parameters.push(eventData.redirectParameters.join('&'));
96+
res.backUrl = parameters.join('#');
97+
}
8798
window.location = res.backUrl;
8899
return;
89100
}

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/Controller/Cart/CouponPost.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,17 @@ public function execute()
9090

9191
if ($codeLength) {
9292
$escaper = $this->_objectManager->get(\Magento\Framework\Escaper::class);
93+
$coupon = $this->couponFactory->create();
94+
$coupon->load($couponCode, 'code');
9395
if (!$itemsCount) {
94-
if ($isCodeLengthValid) {
95-
$coupon = $this->couponFactory->create();
96-
$coupon->load($couponCode, 'code');
97-
if ($coupon->getId()) {
98-
$this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save();
99-
$this->messageManager->addSuccess(
100-
__(
101-
'You used coupon code "%1".',
102-
$escaper->escapeHtml($couponCode)
103-
)
104-
);
105-
} else {
106-
$this->messageManager->addError(
107-
__(
108-
'The coupon code "%1" is not valid.',
109-
$escaper->escapeHtml($couponCode)
110-
)
111-
);
112-
}
96+
if ($isCodeLengthValid && $coupon->getId()) {
97+
$this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save();
98+
$this->messageManager->addSuccess(
99+
__(
100+
'You used coupon code "%1".',
101+
$escaper->escapeHtml($couponCode)
102+
)
103+
);
113104
} else {
114105
$this->messageManager->addError(
115106
__(
@@ -119,7 +110,7 @@ public function execute()
119110
);
120111
}
121112
} else {
122-
if ($isCodeLengthValid && $couponCode == $cartQuote->getCouponCode()) {
113+
if ($isCodeLengthValid && $coupon->getId() && $couponCode == $cartQuote->getCouponCode()) {
123114
$this->messageManager->addSuccess(
124115
__(
125116
'You used coupon code "%1".',

app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ class CouponPostTest extends \PHPUnit_Framework_TestCase
6969
*/
7070
protected $quoteRepository;
7171

72+
/**
73+
* @var \PHPUnit_Framework_MockObject_MockObject
74+
*/
75+
private $redirect;
76+
77+
/**
78+
* @var \PHPUnit_Framework_MockObject_MockObject
79+
*/
80+
private $redirectFactory;
81+
7282
/**
7383
* @return void
7484
*/
@@ -204,6 +214,12 @@ public function testExecuteWithGoodCouponAndItems()
204214
->method('getCouponCode')
205215
->willReturn('OLDCODE');
206216

217+
$coupon = $this->getMock(\Magento\SalesRule\Model\Coupon::class, [], [], '', false);
218+
$this->couponFactory->expects($this->once())
219+
->method('create')
220+
->willReturn($coupon);
221+
$coupon->expects($this->once())->method('load')->willReturnSelf();
222+
$coupon->expects($this->once())->method('getId')->willReturn(1);
207223
$this->quote->expects($this->any())
208224
->method('getItemsCount')
209225
->willReturn(1);

0 commit comments

Comments
 (0)