Skip to content

Commit 4b7e09b

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-pr40
2 parents d25e8e6 + ea30f6f commit 4b7e09b

File tree

23 files changed

+297
-37
lines changed

23 files changed

+297
-37
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public function execute()
102102
$this->productBuilder->build($this->getRequest())
103103
);
104104
$this->productTypeManager->processProduct($product);
105-
106105
if (isset($data['product'][$product->getIdFieldName()])) {
107106
throw new \Magento\Framework\Exception\LocalizedException(__('Unable to save product'));
108107
}
109108

110109
$originalSku = $product->getSku();
110+
$canSaveCustomOptions = $product->getCanSaveCustomOptions();
111111
$product->save();
112112
$this->handleImageRemoveError($data, $product->getId());
113113
$this->getCategoryLinkManagement()->assignProductToCategories(
@@ -117,8 +117,9 @@ public function execute()
117117
$productId = $product->getEntityId();
118118
$productAttributeSetId = $product->getAttributeSetId();
119119
$productTypeId = $product->getTypeId();
120-
121-
$this->copyToStores($data, $productId);
120+
$extendedData = $data;
121+
$extendedData['can_save_custom_options'] = $canSaveCustomOptions;
122+
$this->copyToStores($extendedData, $productId);
122123

123124
$this->messageManager->addSuccessMessage(__('You saved the product.'));
124125
$this->getDataPersistor()->clear('catalog_product');
@@ -238,6 +239,7 @@ protected function copyToStores($data, $productId)
238239
->setStoreId($copyFrom)
239240
->load($productId)
240241
->setStoreId($copyTo)
242+
->setCanSaveCustomOptions($data['can_save_custom_options'])
241243
->setCopyFromView(true)
242244
->save();
243245
}

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductCustomizableOptionsSection.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<element name="useDefaultOptionTitle" type="text" selector="[data-index='options'] tr.data-row [data-index='title'] [name^='options_use_default']"/>
1515
<element name="useDefaultOptionValueTitleByIndex" type="text" selector="[data-index='options'] [data-index='values'] tr[data-repeat-index='{{var1}}'] [name^='options_use_default']" parameterized="true"/>
1616
<element name="addOptionBtn" type="button" selector="button[data-index='button_add']"/>
17-
<element name="fillOptionTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Title']/parent::label/parent::div//input[@class='admin__control-text']" parameterized="true"/>
18-
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Type']/parent::label/parent::div//div[@data-role='selected-option']" parameterized="true"/>
17+
<element name="fillOptionTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//label[text()='Option Title']/parent::span/parent::div//input[@class='admin__control-text']" parameterized="true"/>
18+
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//label[text()='Option Type']/parent::span/parent::div//div[@data-role='selected-option']" parameterized="true"/>
1919
<element name="checkDropDown" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//parent::label/parent::div//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='Drop-down']" parameterized="true"/>
2020
<element name="clickAddValue" type="button" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tfoot//button" parameterized="true"/>
21-
<element name="fillOptionValueTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//span[text()='Title']/parent::label/parent::div//div[@class='admin__field-control']/input" parameterized="true"/>
21+
<element name="fillOptionValueTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//label[text()='Title']/parent::span/parent::div//div[@class='admin__field-control']/input" parameterized="true"/>
2222
<element name="fillOptionValuePrice" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//span[text()='Price']/parent::label/parent::div//div[@class='admin__control-addon']/input" parameterized="true"/>
23-
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//span[text()='Price Type']/parent::label/parent::div//select" parameterized="true"/>
23+
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//label[text()='Price Type']/parent::span/parent::div//select" parameterized="true"/>
2424
<!-- Elements that make it easier to select the most recently added element -->
2525
<element name="lastOptionTitle" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, '_required')]//input" />
2626
<element name="lastOptionTypeParent" type="block" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__action-multiselect-text')]" />

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
1616
<element name="productNameUseDefault" type="checkbox" selector="input[name='use_default[name]']"/>
1717
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
18+
<element name="enableProductAttributeLabel" type="text" selector="[data-index='status'] .admin__field-label label"/>
19+
<element name="enableProductAttributeLabelWrapper" type="text" selector="[data-index='status'] .admin__field-label"/>
1820
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
1921
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
2022
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
@@ -31,7 +33,7 @@
3133
<element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/>
3234
<element name="divByDataIndex" type="input" selector="div[data-index='{{var}}']" parameterized="true"/>
3335
<element name="attributeSetSearchCount" type="text" selector="div[data-index='attribute_set_id'] .admin__action-multiselect-search-count"/>
34-
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
36+
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//label[text()='{{attributeLabel}}']" parameterized="true"/>
3537
<element name="addAttributeBtn" type="button" selector="#addAttribute"/>
3638
</section>
3739
<section name="ProductInWebsitesSection">

app/code/Magento/Catalog/Test/Mftf/Test/AdminMultipleWebsitesUseDefaultValuesTest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@
4040

4141
<!--Create a Simple Product -->
4242
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
43-
<waitForPageLoad time="30" stepKey="waitForProductsGridPageLoad"/>
43+
<waitForPageLoad stepKey="waitForProductsGridPageLoad"/>
4444
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
4545
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
46-
<!-- Need to wait because fields are loaded a little bit later then it starts to fill them -->
47-
<waitForElementVisible selector="{{AdminProductFormSection.productName}}" stepKey="waitForNameFieldVisible"/>
46+
<waitForPageLoad stepKey="waitForPageProductFormLoad"/>
4847
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillProductName"/>
4948
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillProductSKU"/>
5049
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillProductPrice"/>
@@ -54,7 +53,7 @@
5453
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsites"/>
5554
<click selector="{{ProductInWebsitesSection.website('Second Website')}}" stepKey="selectSecondWebsite"/>
5655
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/>
57-
<waitForLoadingMaskToDisappear stepKey="waitForProductPageSave"/>
56+
<waitForPageLoad stepKey="waitForProductSave"/>
5857
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
5958

6059
<!-- switch to the second store view -->

app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public function getCountTotals()
298298
);
299299

300300
$this->_addOrderStatusFilter($totalsCollection, $filterData);
301+
$this->_addCustomFilter($totalsCollection, $filterData);
301302

302303
if ($totalsCollection->load()->getSize() < 1 || !$filterData->getData('from')) {
303304
$this->setTotals(new \Magento\Framework\DataObject());
@@ -309,6 +310,7 @@ public function getCountTotals()
309310
}
310311
}
311312
}
313+
312314
return parent::getCountTotals();
313315
}
314316

@@ -407,7 +409,6 @@ protected function _addCustomFilter($collection, $filterData)
407409
}
408410

409411
/**
410-
*
411412
* @return array
412413
* @throws \Magento\Framework\Exception\LocalizedException
413414
*/
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Coupons;
9+
10+
/**
11+
* Test for class \Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid
12+
*/
13+
class GridTest extends \PHPUnit\Framework\TestCase
14+
{
15+
/**
16+
* @var \Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid
17+
*/
18+
private $model;
19+
20+
/**
21+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $storeManagerMock;
24+
25+
/**
26+
* @var \Magento\Reports\Model\ResourceModel\Report\Collection\Factory|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
private $resourceFactoryMock;
29+
30+
protected function setUp()
31+
{
32+
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
33+
->getMock();
34+
$this->resourceFactoryMock = $this
35+
->getMockBuilder(\Magento\Reports\Model\ResourceModel\Report\Collection\Factory::class)
36+
->disableOriginalConstructor()
37+
->getMock();
38+
$aggregatedColumns = [1 => 'SUM(value)'];
39+
40+
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
41+
$this->model = $objectManager->getObject(
42+
\Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid::class,
43+
[
44+
'_storeManager' => $this->storeManagerMock,
45+
'_aggregatedColumns' => $aggregatedColumns,
46+
'resourceFactory' => $this->resourceFactoryMock,
47+
]
48+
);
49+
}
50+
51+
/**
52+
* @dataProvider getCountTotalsDataProvider
53+
*
54+
* @param string $reportType
55+
* @param int $priceRuleType
56+
* @param int $collectionSize
57+
* @param bool $expectedCountTotals
58+
*/
59+
public function testGetCountTotals(
60+
string $reportType,
61+
int $priceRuleType,
62+
int $collectionSize,
63+
bool $expectedCountTotals
64+
) {
65+
$filterData = new \Magento\Framework\DataObject();
66+
$filterData->setData('report_type', $reportType);
67+
$filterData->setData('period_type', 'day');
68+
$filterData->setData('from', '2000-01-01');
69+
$filterData->setData('to', '2000-01-30');
70+
$filterData->setData('store_ids', '1');
71+
$filterData->setData('price_rule_type', $priceRuleType);
72+
if ($priceRuleType) {
73+
$filterData->setData('rules_list', ['0,1']);
74+
}
75+
$filterData->setData('order_statuses', 'statuses');
76+
$this->model->setFilterData($filterData);
77+
78+
$resourceCollectionName = $this->model->getResourceCollectionName();
79+
$collectionMock = $this->buildBaseCollectionMock($filterData, $resourceCollectionName, $collectionSize);
80+
81+
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
82+
->getMock();
83+
$this->storeManagerMock->method('getStores')
84+
->willReturn([1 => $store]);
85+
$this->resourceFactoryMock->expects($this->once())
86+
->method('create')
87+
->willReturn($collectionMock);
88+
89+
$this->assertEquals($expectedCountTotals, $this->model->getCountTotals());
90+
}
91+
92+
/**
93+
* @return array
94+
*/
95+
public function getCountTotalsDataProvider(): array
96+
{
97+
return [
98+
['created_at_shipment', 0, 0, false],
99+
['created_at_shipment', 0, 1, true],
100+
['updated_at_order', 0, 1, true],
101+
['updated_at_order', 1, 1, true],
102+
];
103+
}
104+
105+
/**
106+
* @param \Magento\Framework\DataObject $filterData
107+
* @param string $resourceCollectionName
108+
* @param int $collectionSize
109+
* @return \PHPUnit_Framework_MockObject_MockObject
110+
*/
111+
private function buildBaseCollectionMock(
112+
\Magento\Framework\DataObject $filterData,
113+
string $resourceCollectionName,
114+
int $collectionSize
115+
): \PHPUnit_Framework_MockObject_MockObject {
116+
$collectionMock = $this->getMockBuilder($resourceCollectionName)
117+
->disableOriginalConstructor()
118+
->getMock();
119+
$collectionMock->expects($this->once())
120+
->method('setPeriod')
121+
->with($filterData->getData('period_type'))
122+
->willReturnSelf();
123+
$collectionMock->expects($this->once())
124+
->method('setDateRange')
125+
->with($filterData->getData('from'), $filterData->getData('to'))
126+
->willReturnSelf();
127+
$collectionMock->expects($this->once())
128+
->method('addStoreFilter')
129+
->with(\explode(',', $filterData->getData('store_ids')))
130+
->willReturnSelf();
131+
$collectionMock->expects($this->once())
132+
->method('setAggregatedColumns')
133+
->willReturnSelf();
134+
$collectionMock->expects($this->once())
135+
->method('isTotals')
136+
->with(true)
137+
->willReturnSelf();
138+
$collectionMock->expects($this->once())
139+
->method('addOrderStatusFilter')
140+
->with($filterData->getData('order_statuses'))
141+
->willReturnSelf();
142+
143+
if ($filterData->getData('price_rule_type')) {
144+
$collectionMock->expects($this->once())
145+
->method('addRuleFilter')
146+
->with(\explode(',', $filterData->getData('rules_list')[0]))
147+
->willReturnSelf();
148+
}
149+
150+
$collectionMock->expects($this->once())
151+
->method('load')
152+
->willReturnSelf();
153+
$collectionMock->expects($this->once())
154+
->method('getSize')
155+
->willReturn($collectionSize);
156+
if ($collectionSize) {
157+
$itemMock = $this->getMockBuilder(\Magento\Reports\Model\Item::class)
158+
->disableOriginalConstructor()
159+
->getMock();
160+
$collectionMock->expects($this->once())
161+
->method('getItems')
162+
->willReturn([$itemMock]);
163+
}
164+
165+
return $collectionMock;
166+
}
167+
}

app/code/Magento/Ui/view/base/web/templates/form/field.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
visible="visible"
99
css="$data.additionalClasses"
1010
attr="'data-index': index">
11-
<label class="admin__field-label" if="$data.label" visible="$data.labelVisible" attr="for: uid">
12-
<span translate="label" attr="'data-config-scope': $data.scopeLabel"/>
13-
</label>
11+
<span class="admin__field-label" if="$data.label" visible="$data.labelVisible">
12+
<label translate="label" attr="'data-config-scope': $data.scopeLabel, for: uid"/>
13+
</span>
1414
<div class="admin__field-control"
1515
css="'_with-tooltip': $data.tooltip, '_with-reset': $data.showFallbackReset && $data.isDifferedFromDefault">
1616
<render args="elementTmpl" ifnot="hasAddons()"/>

app/code/Magento/Wishlist/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public function calculate()
576576
) {
577577
$count = $collection->getItemsQty();
578578
} else {
579-
$count = $collection->getSize();
579+
$count = $collection->count();
580580
}
581581
$this->_customerSession->setWishlistDisplayType(
582582
$this->scopeConfig->getValue(

app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ protected function _assignProducts()
307307

308308
$checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
309309

310+
/** @var \Magento\Wishlist\Model\Item $item */
310311
foreach ($this as $item) {
311312
$product = $productCollection->getItemById($item->getProductId());
312313
if ($product) {
@@ -320,7 +321,7 @@ protected function _assignProducts()
320321
$item->setPrice($product->getPrice());
321322
}
322323
} else {
323-
$item->isDeleted(true);
324+
$this->removeItemByKey($item->getId());
324325
}
325326
}
326327

app/code/Magento/Wishlist/Model/Wishlist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public function setStore($store)
582582
*/
583583
public function getItemsCount()
584584
{
585-
return $this->getItemCollection()->getSize();
585+
return $this->getItemCollection()->count();
586586
}
587587

588588
/**

0 commit comments

Comments
 (0)