Skip to content

Commit 3f148f9

Browse files
author
Kopylova,Olga(okopylova)
committed
Merge pull request #251 from magento-goinc/pr-11.12
[SWAT] Bug fixes
2 parents 81ee51c + fe76bca commit 3f148f9

File tree

13 files changed

+170
-55
lines changed

13 files changed

+170
-55
lines changed

app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,10 @@ jQuery(window).load(function() {
306306

307307
});
308308
</script>
309+
<script type="text/x-magento-init">
310+
{
311+
"*": {
312+
"Magento_Bundle/js/bundle-type-handler": {}
313+
}
314+
}
315+
</script>

app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Attributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
1313

14-
class Attributes extends \Magento\Backend\Block\Widget\Form\Generic
14+
class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
1515
{
1616
/**
1717
* Retrieve Category object

app/code/Magento/Catalog/Setup/InstallData.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
8989
$categorySetup->updateAttributeGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'sort_order', '10');
9090

9191
$groups = [
92-
'display' => ['name' => 'Display Settings', 'sort' => 20, 'id' => null],
93-
'design' => ['name' => 'Custom Design', 'sort' => 30, 'id' => null],
92+
'display' => ['name' => 'Display Settings', 'code' => 'display-settings', 'sort' => 20, 'id' => null],
93+
'design' => ['name' => 'Custom Design', 'code' => 'custom-design', 'sort' => 30, 'id' => null],
9494
];
9595

9696
foreach ($groups as $k => $groupProp) {
9797
$categorySetup->addAttributeGroup($entityTypeId, $attributeSetId, $groupProp['name'], $groupProp['sort']);
98-
$groups[$k]['id'] = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, $groupProp['name']);
98+
$groups[$k]['id'] = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, $groupProp['code']);
9999
}
100100

101101
// update attributes group and sort
@@ -183,25 +183,25 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
183183
$tabNames = [
184184
'General' => [
185185
'attribute_group_name' => $newGeneralTabName,
186-
'attribute_group_code' => preg_replace('/[^a-z0-9]+/', '-', strtolower($newGeneralTabName)),
186+
'attribute_group_code' => $categorySetup->convertToAttributeGroupCode($newGeneralTabName),
187187
'tab_group_code' => 'basic',
188188
'sort_order' => 10,
189189
],
190190
'Images' => [
191191
'attribute_group_name' => $newImagesTabName,
192-
'attribute_group_code' => preg_replace('/[^a-z0-9]+/', '-', strtolower($newImagesTabName)),
192+
'attribute_group_code' => $categorySetup->convertToAttributeGroupCode($newImagesTabName),
193193
'tab_group_code' => 'basic',
194194
'sort_order' => 20,
195195
],
196196
'Meta Information' => [
197197
'attribute_group_name' => $newMetaTabName,
198-
'attribute_group_code' => preg_replace('/[^a-z0-9]+/', '-', strtolower($newMetaTabName)),
198+
'attribute_group_code' => $categorySetup->convertToAttributeGroupCode($newMetaTabName),
199199
'tab_group_code' => 'basic',
200200
'sort_order' => 30,
201201
],
202202
'Prices' => [
203203
'attribute_group_name' => $newPriceTabName,
204-
'attribute_group_code' => preg_replace('/[^a-z0-9]+/', '-', strtolower($newPriceTabName)),
204+
'attribute_group_code' => $categorySetup->convertToAttributeGroupCode($newPriceTabName),
205205
'tab_group_code' => 'advanced',
206206
'sort_order' => 40,
207207
],

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ define([
1616
*/
1717
init: function () {
1818

19-
if (weight.productHasWeight()) {
19+
//not weight switcher for specific product
20+
if (weight.productHasWeightBySwitcher() && weight.hasWeightSwither()) {
2021
this.type = {
2122
virtual: 'virtual',
2223
real: this.$type.val() //simple, configurable

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

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,102 @@ define([
1010

1111
return {
1212

13-
$weightSwitcher: $('[data-role=weight-switcher]'),
14-
$weight: $('#weight'),
13+
/**
14+
* Get weight
15+
* @returns {*|jQuery|HTMLElement}
16+
*/
17+
$weight: function () {
18+
return $('#weight');
19+
},
1520

1621
/**
17-
* Hide weight switcher
22+
* Weight Switcher
23+
* @returns {*|jQuery|HTMLElement}
1824
*/
19-
hideWeightSwitcher: function () {
20-
this.$weightSwitcher.hide();
25+
$weightSwitcher: function () {
26+
return $('[data-role=weight-switcher]');
2127
},
2228

2329
/**
2430
* Is locked
2531
* @returns {*}
2632
*/
2733
isLocked: function () {
28-
return this.$weight.is('[data-locked]');
34+
return this.$weight().is('[data-locked]');
2935
},
3036

3137
/**
3238
* Disabled
3339
*/
3440
disabled: function () {
35-
this.$weight.addClass('ignore-validate').prop('disabled', true);
41+
this.$weight().addClass('ignore-validate').prop('disabled', true);
3642
},
3743

3844
/**
3945
* Enabled
4046
*/
4147
enabled: function () {
42-
this.$weight.removeClass('ignore-validate').prop('disabled', false);
48+
this.$weight().removeClass('ignore-validate').prop('disabled', false);
4349
},
4450

4551
/**
4652
* Switch Weight
4753
* @returns {*}
4854
*/
4955
switchWeight: function () {
50-
return this.productHasWeight() ? this.enabled() : this.disabled();
56+
return this.productHasWeightBySwitcher() ? this.enabled() : this.disabled();
5157
},
5258

5359
/**
54-
* Product has weight
55-
* @returns {Bool}
60+
* Hide weight switcher
5661
*/
57-
productHasWeight: function () {
58-
return $('input:checked', this.$weightSwitcher).val() === '1';
62+
hideWeightSwitcher: function () {
63+
this.$weightSwitcher().hide();
5964
},
6065

6166
/**
62-
* Notify product weight is changed
63-
* @returns {*|jQuery}
67+
* Has weight swither
68+
* @returns {*}
6469
*/
65-
notifyProductWeightIsChanged: function () {
66-
return $('input:checked', this.$weightSwitcher).trigger('change');
70+
hasWeightSwither: function () {
71+
return this.$weightSwitcher().is(':visible');
72+
},
73+
74+
/**
75+
* Product has weight
76+
* @returns {Bool}
77+
*/
78+
productHasWeightBySwitcher: function () {
79+
return $('input:checked', this.$weightSwitcher()).val() === '1';
6780
},
6881

6982
/**
7083
* Change
7184
* @param {String} data
7285
*/
7386
change: function (data) {
74-
var value = data !== undefined ? +data : !this.productHasWeight();
87+
var value = data !== undefined ? +data : !this.productHasWeightBySwitcher();
7588

76-
$('input[value=' + value + ']', this.$weightSwitcher).prop('checked', true);
89+
$('input[value=' + value + ']', this.$weightSwitcher()).prop('checked', true);
90+
this.switchWeight();
7791
},
7892

7993
/**
8094
* Constructor component
8195
*/
8296
'Magento_Catalog/js/product/weight-handler': function () {
8397
this.bindAll();
84-
this.switchWeight();
98+
99+
if (this.hasWeightSwither()) {
100+
this.switchWeight();
101+
}
85102
},
86103

87104
/**
88105
* Bind all
89106
*/
90107
bindAll: function () {
91-
this.$weightSwitcher.find('input').on('change', this.switchWeight.bind(this));
108+
this.$weightSwitcher().find('input').on('change', this.switchWeight.bind(this));
92109
}
93110
};
94111
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define([
6161
_initType: function () {
6262
if (productType.type.current === 'downloadable') {
6363
weight.change(false);
64-
weight.$weightSwitcher.one('change', function () {
64+
weight.$weightSwitcher().one('change', function () {
6565
$(document).trigger('setTypeProduct', null);
6666
});
6767
this.show();

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212
*/
1313
class Group extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
1414
{
15-
/**
16-
* Constants for attribute group codes
17-
*/
18-
const TAB_GENERAL_CODE = 'product-details';
19-
20-
const TAB_IMAGE_MANAGEMENT_CODE = 'image-management';
21-
2215
/**
2316
* Resource initialization
2417
*

app/code/Magento/Eav/Setup/EavSetup.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class EavSetup
5959
*
6060
* @var array
6161
*/
62-
private $defaultGroupIdAssociations = ['General' => 1];
62+
private $defaultGroupIdAssociations = ['general' => 1];
6363

6464
/**
6565
* Default attribute group name
@@ -134,12 +134,12 @@ public function cleanCache()
134134
public function installDefaultGroupIds()
135135
{
136136
$setIds = $this->getAllAttributeSetIds();
137-
foreach ($this->defaultGroupIdAssociations as $defaultGroupName => $defaultGroupId) {
137+
foreach ($this->defaultGroupIdAssociations as $defaultGroupCode => $defaultGroupId) {
138138
foreach ($setIds as $set) {
139139
$groupId = $this->setup->getTableRow(
140140
'eav_attribute_group',
141-
'attribute_group_name',
142-
$defaultGroupName,
141+
'attribute_group_code',
142+
$defaultGroupCode,
143143
'attribute_group_id',
144144
'attribute_set_id',
145145
$set
@@ -511,24 +511,24 @@ public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = nul
511511
{
512512
$setId = $this->getAttributeSetId($entityTypeId, $setId);
513513
$data = ['attribute_set_id' => $setId, 'attribute_group_name' => $name];
514+
$attributeGroupCode = $this->convertToAttributeGroupCode($name);
514515

515-
if (isset($this->defaultGroupIdAssociations[$name])) {
516-
$data['default_id'] = $this->defaultGroupIdAssociations[$name];
516+
if (isset($this->defaultGroupIdAssociations[$attributeGroupCode])) {
517+
$data['default_id'] = $this->defaultGroupIdAssociations[$attributeGroupCode];
517518
}
518519

519520
if ($sortOrder !== null) {
520521
$data['sort_order'] = $sortOrder;
521522
}
522523

523-
$groupId = $this->getAttributeGroup($entityTypeId, $setId, $name, 'attribute_group_id');
524+
$groupId = $this->getAttributeGroup($entityTypeId, $setId, $attributeGroupCode, 'attribute_group_id');
524525
if ($groupId) {
525526
$this->updateAttributeGroup($entityTypeId, $setId, $groupId, $data);
526527
} else {
527528
if ($sortOrder === null) {
528529
$data['sort_order'] = $this->getAttributeGroupSortOrder($entityTypeId, $setId, $sortOrder);
529530
}
530531
if (empty($data['attribute_group_code'])) {
531-
$attributeGroupCode = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($name)), '-');
532532
if (empty($attributeGroupCode)) {
533533
// in the following code md5 is not used for security purposes
534534
$attributeGroupCode = md5($name);
@@ -541,6 +541,15 @@ public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = nul
541541
return $this;
542542
}
543543

544+
/**
545+
* @param string $groupName
546+
* @return string
547+
*/
548+
public function convertToAttributeGroupCode($groupName)
549+
{
550+
return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($groupName)), '-');
551+
}
552+
544553
/**
545554
* Update Attribute Group Data
546555
*
@@ -577,22 +586,22 @@ public function updateAttributeGroup($entityTypeId, $setId, $id, $field, $value
577586
*/
578587
public function getAttributeGroup($entityTypeId, $setId, $id, $field = null)
579588
{
580-
$searchId = $id;
581589
if (is_numeric($id)) {
582590
$searchField = 'attribute_group_id';
583591
} else {
592+
$id = $this->convertToAttributeGroupCode($id);
584593
if (isset($this->defaultGroupIdAssociations[$id])) {
585594
$searchField = 'default_id';
586-
$searchId = $this->defaultGroupIdAssociations[$id];
595+
$id = $this->defaultGroupIdAssociations[$id];
587596
} else {
588-
$searchField = 'attribute_group_name';
597+
$searchField = 'attribute_group_code';
589598
}
590599
}
591600

592601
return $this->setup->getTableRow(
593602
'eav_attribute_group',
594603
$searchField,
595-
$searchId,
604+
$id,
596605
$field,
597606
'attribute_set_id',
598607
$this->getAttributeSetId($entityTypeId, $setId)

app/code/Magento/ProductVideo/Setup/UpgradeData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
5151
$attributeGroup = $categorySetup->getAttributeGroup(
5252
$entityTypeId,
5353
$attributeSetId,
54-
'Image Management'
54+
'image-management'
5555
);
5656
if (isset($attributeGroup['attribute_group_name'])
5757
&& $attributeGroup['attribute_group_name'] == 'Image Management'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Page\Product\CatalogProductView;
10+
use Magento\Customer\Test\Fixture\Customer;
11+
use Magento\Mtf\Client\BrowserInterface;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\Mtf\Fixture\FixtureInterface;
14+
15+
/**
16+
* Assert that displayed tier price on product page equals passed from fixture for specified customer.
17+
*/
18+
class AssertProductTierPriceOnProductPageWithCustomer extends AbstractConstraint
19+
{
20+
/**
21+
* Assertion that tier prices are displayed correctly for specified customer
22+
*
23+
* @param BrowserInterface $browser
24+
* @param CatalogProductView $catalogProductView
25+
* @param FixtureInterface $product
26+
* @param Customer $customer
27+
* @return void
28+
*/
29+
public function processAssert(
30+
BrowserInterface $browser,
31+
CatalogProductView $catalogProductView,
32+
FixtureInterface $product,
33+
Customer $customer
34+
) {
35+
$customer->persist();
36+
$this->loginCustomer($customer);
37+
38+
$productTierPriceAssert = $this->objectManager->get(
39+
'Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage'
40+
);
41+
$productTierPriceAssert->processAssert($browser, $catalogProductView, $product);
42+
}
43+
44+
/**
45+
* Login customer
46+
*
47+
* @param Customer $customer
48+
*
49+
* @return void
50+
*/
51+
protected function loginCustomer($customer)
52+
{
53+
$this->objectManager->create(
54+
'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep',
55+
['customer' => $customer]
56+
)->run();
57+
}
58+
59+
/**
60+
* Returns a string representation of the object
61+
*
62+
* @return string
63+
*/
64+
public function toString()
65+
{
66+
return 'Tier price is displayed on the product page for specific customer.';
67+
}
68+
}

0 commit comments

Comments
 (0)