Skip to content

Commit c58d2da

Browse files
author
Slabko,Michael(mslabko)
committed
Merge pull request #273 from magento-goinc/pr-273
[SWAT] Bug fixes
2 parents a661471 + e79b362 commit c58d2da

File tree

16 files changed

+68
-45
lines changed

16 files changed

+68
-45
lines changed

app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ define([
3333
*/
3434
_initType: function () {
3535
if (
36-
productType.type.real === 'bundle' &&
36+
productType.type.init === 'bundle' &&
3737
productType.type.current !== 'bundle' &&
3838
!weight.isLocked()
3939
) {

app/code/Magento/Catalog/view/adminhtml/web/catalog/apply-to-type-switcher.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
*/
55
define([
66
'jquery',
7-
'Magento_Catalog/js/product/weight-handler',
87
'Magento_Catalog/catalog/type-events'
9-
], function ($, weight, productType) {
8+
], function ($, productType) {
109
'use strict';
1110

1211
return {

app/code/Magento/Catalog/view/adminhtml/web/catalog/type-events.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6-
'jquery',
7-
'Magento_Catalog/js/product/weight-handler'
8-
], function ($, weight) {
6+
'jquery'
7+
], function ($) {
98
'use strict';
109

1110
return {
@@ -15,20 +14,10 @@ define([
1514
* Init
1615
*/
1716
init: function () {
18-
19-
//not weight switcher for specific product
20-
if (weight.productHasWeightBySwitcher() && weight.hasWeightSwither()) {
21-
this.type = {
22-
virtual: 'virtual',
23-
real: this.$type.val() //simple, configurable
24-
};
25-
} else {
26-
this.type = {
27-
virtual: this.$type.val(), //downloadable, virtual, grouped, bundle
28-
real: 'simple'
29-
};
30-
}
31-
this.type.current = this.$type.val();
17+
this.type = {
18+
init: this.$type.val(),
19+
current: this.$type.val()
20+
};
3221

3322
this.bindAll();
3423
},
@@ -54,7 +43,7 @@ define([
5443
* @returns {*}
5544
*/
5645
setType: function (type) {
57-
return this.$type.val(type || this.type.real).trigger('change');
46+
return this.$type.val(type || this.type.init).trigger('change');
5847
},
5948

6049
/**

app/code/Magento/Catalog/view/adminhtml/web/js/product/weight-handler.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ define([
7171
return this.$weightSwitcher().is(':visible');
7272
},
7373

74+
/**
75+
* Has weight
76+
* @returns {*}
77+
*/
78+
hasWeight: function () {
79+
return this.$weight.is(':visible');
80+
},
81+
7482
/**
7583
* Product has weight
7684
* @returns {Bool}

app/code/Magento/CatalogUrlRewrite/etc/adminhtml/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<plugin name="category_move_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Move"/>
1717
<plugin name="category_delete_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Remove"/>
1818
</type>
19-
<type name="Magento\UrlRewrite\Model\StorageInterface">
20-
<plugin name="storage_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Storage"/>
21-
</type>
2219
<type name="Magento\Catalog\Block\Adminhtml\Category\Tab\Attributes">
2320
<plugin name="category_form_url_key_plugin" type="Magento\CatalogUrlRewrite\Plugin\Catalog\Block\Adminhtml\Category\Tab\Attributes"/>
2421
</type>

app/code/Magento/CatalogUrlRewrite/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@
2020
<plugin name="category_move_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Move"/>
2121
<plugin name="category_delete_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Remove"/>
2222
</type>
23+
<type name="Magento\UrlRewrite\Model\StorageInterface">
24+
<plugin name="storage_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Storage"/>
25+
</type>
2326
</config>

app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ class Config extends Widget implements TabInterface
2727
*/
2828
protected $_coreRegistry;
2929

30+
/**
31+
* @var Configurable
32+
*/
33+
protected $configurableType;
34+
3035
/**
3136
* @param \Magento\Backend\Block\Template\Context $context
3237
* @param \Magento\Framework\Registry $coreRegistry
38+
* @param Configurable $configurableType
3339
* @param array $data
3440
*/
3541
public function __construct(
3642
\Magento\Backend\Block\Template\Context $context,
3743
\Magento\Framework\Registry $coreRegistry,
44+
Configurable $configurableType,
3845
array $data = []
3946
) {
4047
$this->_coreRegistry = $coreRegistry;
48+
$this->configurableType = $configurableType;
4149
parent::__construct($context, $data);
4250
}
4351

@@ -129,17 +137,18 @@ public function getParentTab()
129137
/**
130138
* @return bool
131139
*/
132-
public function isConfigurableProduct()
140+
public function isHasVariations()
133141
{
134-
return $this->getProduct()->getTypeId() === Configurable::TYPE_CODE || $this->getRequest()->has('attributes');
142+
return $this->getProduct()->getTypeId() === Configurable::TYPE_CODE
143+
&& $this->configurableType->getUsedProducts($this->getProduct());
135144
}
136145

137146
/**
138147
* @return $this
139148
*/
140149
protected function _prepareLayout()
141150
{
142-
$this->setData('opened', $this->isConfigurableProduct());
151+
$this->setData('opened', $this->getProduct()->getTypeId() === Configurable::TYPE_CODE);
143152
return parent::_prepareLayout();
144153
}
145154
}

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<button type="button" data-action="open-steps-wizard" title="Create Product Configurations"
2222
class="action-secondary" data-bind="click: open">
2323
<span data-role="button-label" data-edit-label="<?= /* @escapeNotVerified */ __('Edit Configurations') ?>">
24-
<?= /* @escapeNotVerified */ $block->getProduct()->getId() && $block->isConfigurableProduct()
24+
<?= /* @escapeNotVerified */ $block->isHasVariations()
2525
? __('Edit Configurations')
2626
: __('Create Configurations')
2727
?>
@@ -74,7 +74,7 @@
7474
"Magento_ConfigurableProduct/js/configurable-type-handler": {
7575
"blockId": "#<?= /* @noEscape */ $block->getId()?>",
7676
"tabId": "<?= /* @noEscape */ $block->getTabId()?>",
77-
"hasVariations": "<?= /* @noEscape */ $block->isConfigurableProduct() ? 'true' : 'false' ?>"
77+
"hasVariations": <?= /* @noEscape */ $block->isHasVariations() ? 'true' : 'false' ?>
7878
}
7979
}
8080
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable-type-handler.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ define([
7171
*/
7272
bindAll: function () {
7373
$(document).on('changeConfigurableTypeProduct', function (event, isConfigurable) {
74-
$(document).trigger('setTypeProduct', isConfigurable ? 'configurable' : null);
74+
$(document).trigger('setTypeProduct', isConfigurable ?
75+
'configurable' :
76+
productType.type.init === 'configurable' ? 'simple' : productType.type.init
77+
);
7578
});
7679
$(document).on('changeTypeProduct', this._initType.bind(this));
7780
},
@@ -84,16 +87,15 @@ define([
8487
var suggestContainer = $('#product-template-suggest-container .action-dropdown > .action-toggle');
8588

8689
if (productType.type.current === 'configurable') {
87-
suggestContainer.addClass('disabled').prop('disabled', true);
88-
$('#inventory_qty').prop('disabled', true);
89-
$('#inventory_stock_availability').removeProp('disabled');
90+
this._setElementDisabled(suggestContainer.addClass('disabled'), true);
91+
this._setElementDisabled($('#inventory_qty'), true);
92+
this._setElementDisabled($('#inventory_stock_availability'), false);
9093
this._setElementDisabled($('#qty'), true, true);
9194
this._setElementDisabled($('#quantity_and_stock_status'), false, false);
9295
} else {
93-
suggestContainer.removeClass('disabled').removeProp('disabled');
94-
$('#inventory_qty').removeProp('disabled');
95-
$('#inventory_stock_availability').prop('disabled', true);
96-
this._setElementDisabled($('#quantity_and_stock_status'), true, false);
96+
this._setElementDisabled(suggestContainer.removeClass('disabled'), false);
97+
this._setElementDisabled($('#inventory_qty'), false);
98+
this._setElementDisabled($('#inventory_stock_availability'), true);
9799
this._setElementDisabled($('#qty'), false, true);
98100
}
99101

@@ -115,6 +117,10 @@ define([
115117
advancedPricingHandler.init();
116118
priceTypeHandler.init();
117119

120+
if (productType.type.init === 'configurable' && !this.hasVariations) {
121+
$(document).trigger('setTypeProduct', 'simple');
122+
}
123+
118124
this.bindAll();
119125
this._initType();
120126
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ define([
135135
};
136136
},
137137
getProductValue: function (name) {
138-
return $('[name="product[' + name.split('/').join('][') + ']"]', this.productForm).val();
138+
name = name.split('/').join('][');
139+
140+
return $('[name="product[' + name + ']"]:enabled:not(.ignore-validate)', this.productForm).val();
139141
},
140142
getRowId: function (data, field) {
141143
var key = data.variationKey;

app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ require([
208208
'</select>'+
209209
'</td>'+
210210
'<td class="col-limit">' +
211-
'<input type="text" id="downloadable_link_<%- data.id %>_downloads" name="downloadable[link][<%- data.id %>][number_of_downloads]" class="input-text admin__control-text downloads" value="<%- data.number_of_downloads %>" />'+
211+
'<input type="text" id="downloadable_link_<%- data.id %>_downloads" name="downloadable[link][<%- data.id %>][number_of_downloads]" class="input-text validate-zero-or-greater admin__control-text downloads" value="<%- data.number_of_downloads %>" />'+
212212
'<div class="admin__field admin__field-option">' +
213213
'<input type="checkbox" class="admin__control-checkbox" id="downloadable_link_<%- data.id %>_is_unlimited" name="downloadable[link][<%- data.id %>][is_unlimited]" value="1" <%- data.is_unlimited %> />' +
214214
'<label for="downloadable_link_<%- data.id %>_is_unlimited" class="admin__field-label"><span><?php /* @escapeNotVerified */ echo __('Unlimited'); ?></span></label>' +
@@ -470,9 +470,7 @@ require([
470470
};
471471

472472
if (jQuery('input[name="product[links_purchased_separately]"]')) {
473-
jQuery('input[name="product[links_purchased_separately]"]').on('change', function () {
474-
linkItems.togglePriceFields.bind()
475-
});
473+
jQuery('input[name="product[links_purchased_separately]"]').on('change', linkItems.togglePriceFields.bind());
476474
}
477475

478476
if($('add_link_item')) {

app/code/Magento/Downloadable/view/adminhtml/web/downloadable-type-handler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ define([
4848
*/
4949
bindAll: function () {
5050
this.$checkbox.on('change', function (event) {
51-
$(document).trigger('setTypeProduct', $(event.target).prop('checked') ? 'downloadable' : null);
51+
$(document).trigger('setTypeProduct', $(event.target).prop('checked') ?
52+
'downloadable' :
53+
productType.type.init === 'downloadable' ? 'virtual' : productType.type.init
54+
);
5255
});
5356

5457
$(document).on('changeTypeProduct', this._initType.bind(this));

app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ define([
355355
data: 'remote_image=' + sourceUrl,
356356
type: 'post',
357357
success: $.proxy(function (result) {
358-
this._tempPreviewImageData = result;
359-
this._getPreviewImage().attr('src', sourceUrl).show();
358+
if (!this._isEditPage) {
359+
this._tempPreviewImageData = result;
360+
this._getPreviewImage().attr('src', sourceUrl).show();
361+
}
360362
this._blockActionButtons(false, true);
361363
}, self)
362364
});
@@ -1001,6 +1003,7 @@ define([
10011003
_onClose: function () {
10021004
var newVideoForm;
10031005

1006+
this._isEditPage = true;
10041007
this.imageData = null;
10051008

10061009
if (this._previewImage) {

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
<include_in_menu>
2020
<input>select</input>
2121
</include_in_menu>
22+
<use_default_name>
23+
<selector>[name="use_default[]"][value="name"]</selector>
24+
<input>checkbox</input>
25+
</use_default_name>
2226
</fields>
2327
</general_information>
2428
<display_setting>

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<field name="meta_description" is_required="" group="general_information" />
3535
<field name="id" group="null" />
3636
<field name="name" group="general_information" />
37+
<field name="use_default_name" group="general_information"/>
3738
<field name="is_active" group="general_information" />
3839
<field name="is_anchor" group="display_setting" />
3940
<field name="url_key" group="general_information" />

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
</variation>
4949
<variation name="UpdateCategoryEntityTestVariation4" summary="Update Category with custom Store View.">
5050
<data name="category/data/store_id/dataset" xsi:type="string">custom</data>
51+
<data name="category/data/use_default_name" xsi:type="string">No</data>
5152
<data name="category/data/name" xsi:type="string">Category %isolation%</data>
5253
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
5354
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryWithCustomStoreOnFrontend" />

0 commit comments

Comments
 (0)