Skip to content

Commit da140ca

Browse files
committed
Merge remote-tracking branch 'magento2/develop' into PR-11082016
2 parents 7cca67d + e643a67 commit da140ca

File tree

68 files changed

+2015
-254
lines changed

Some content is hidden

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

68 files changed

+2015
-254
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/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/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,4 +1287,19 @@ private function getCatalogConfig()
12871287
}
12881288
return $this->catalogConfig;
12891289
}
1290+
1291+
/**
1292+
* @inheritdoc
1293+
*/
1294+
public function isPossibleBuyFromList($product)
1295+
{
1296+
$isAllCustomOptionsDisplayed = true;
1297+
foreach ($this->getConfigurableAttributes($product) as $attribute) {
1298+
$eavAttribute = $attribute->getProductAttribute();
1299+
1300+
$isAllCustomOptionsDisplayed = ($isAllCustomOptionsDisplayed && $eavAttribute->getUsedInProductListing());
1301+
}
1302+
1303+
return $isAllCustomOptionsDisplayed;
1304+
}
12901305
}

0 commit comments

Comments
 (0)