Skip to content

Commit aa0c29d

Browse files
authored
Merge pull request #3518 from magento-tsg/2.2-develop-pr61
[TSG] Backporting for 2.2 (pr61) (2.2.8)
2 parents b4269c2 + a70652f commit aa0c29d

File tree

51 files changed

+1233
-77
lines changed

Some content is hidden

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

51 files changed

+1233
-77
lines changed

app/code/Magento/Catalog/Model/Category/Product/PositionResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function getPositions(int $categoryId)
5252
$categoryId
5353
)->order(
5454
'ccp.position ' . \Magento\Framework\DB\Select::SQL_ASC
55+
)->order(
56+
'ccp.product_id ' . \Magento\Framework\DB\Select::SQL_DESC
5557
);
5658

5759
return array_flip($connection->fetchCol($select));

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
<click selector="{{AdminProductAttributeGridSection.attributeCode(attributeCode)}}" stepKey="clickRowToEdit"/>
3737
<waitForPageLoad stepKey="waitForColorAttributePageLoad"/>
3838
</actionGroup>
39-
39+
<!--Save product attribute and see success message-->
40+
<actionGroup name="SaveProductAttribute">
41+
<scrollToTopOfPage stepKey="scrollToTop"/>
42+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSaveAttribute"/>
43+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product attribute." stepKey="seeSuccessMessage"/>
44+
</actionGroup>
4045
<actionGroup name="deleteProductAttribute">
4146
<arguments>
4247
<argument name="ProductAttribute"/>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<arguments>
5050
<argument name="attributeSetName" type="string"/>
5151
</arguments>
52+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
5253
<click selector="{{AdminProductFormSection.attributeSet}}" stepKey="startEditAttrSet"/>
5354
<fillField selector="{{AdminProductFormSection.attributeSetFilter}}" userInput="{{attributeSetName}}" stepKey="searchForAttrSet"/>
5455
<waitForAjaxLoad stepKey="waitForLoad"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<element name="productTierPriceValueTypeSelect" type="select" selector="[name='product[tier_price][{{var1}}][value_type]']" parameterized="true"/>
1919
<element name="productTierPriceFixedPriceInput" type="input" selector="[name='product[tier_price][{{var1}}][price]']" parameterized="true"/>
2020
<element name="productTierPricePercentageValuePriceInput" type="input" selector="[name='product[tier_price][{{var1}}][percentage_value]']" parameterized="true"/>
21+
<element name="productTierPricePercentageError" type="text" selector="div[data-index='percentage_value'] label.admin__field-error" />
2122
<element name="specialPrice" type="input" selector="input[name='product[special_price]']"/>
2223
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="5"/>
2324
</section>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminValidateApplyingTierPriceWithEmptyDiscountValueTest">
11+
<annotations>
12+
<features value="Apply tier price"/>
13+
<title value="Apply Tier Price with empty discount value"/>
14+
<description value="Validate applying tier price to product"/>
15+
<stories value="Apply Tier Price with empty discount value" />
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MAGETWO-96484"/>
18+
<group value="product"/>
19+
</annotations>
20+
<before>
21+
<createData entity="_defaultCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
28+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
29+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
30+
<actionGroup ref="AdminResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
31+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
32+
</after>
33+
34+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
35+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
36+
<argument name="product" value="$$createSimpleProduct$$"/>
37+
</actionGroup>
38+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProductPage">
39+
<argument name="product" value="$$createSimpleProduct$$"/>
40+
</actionGroup>
41+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
42+
<click selector="{{AdminProductFormSection.advancedPricingLink}}" stepKey="clickOnAdvancedPricingButton"/>
43+
<waitForElement selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="waitForCustomerGroupPriceAddButton"/>
44+
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceAddButton}}" stepKey="addCustomerGroupPrice"/>
45+
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPriceQtyInput('0')}}" userInput="1" stepKey="fillProductTierPriceQtyInput"/>
46+
<selectOption selector="{{AdminProductFormAdvancedPricingSection.productTierPriceValueTypeSelect('0')}}" userInput="Discount" stepKey="selectProductTierPriceValueType"/>
47+
<clearField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" stepKey="clearPercentageValueField"/>
48+
<click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton"/>
49+
<see selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageError}}" userInput="This is a required field." stepKey="assertPercentageError"/>
50+
<fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" userInput="10" stepKey="setPercentageValue"/>
51+
<click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton1"/>
52+
<dontSee selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageError}}" userInput="This is a required field." stepKey="assertNoPercentageError"/>
53+
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProduct"/>
54+
</test>
55+
</tests>

app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testGetPositions()
105105
$this->select->expects($this->once())
106106
->method('where')
107107
->willReturnSelf();
108-
$this->select->expects($this->once())
108+
$this->select->expects($this->exactly(2))
109109
->method('order')
110110
->willReturnSelf();
111111
$this->select->expects($this->once())

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;
88

9+
use Magento\Catalog\Api\Data\ProductInterface;
10+
use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
911
use Magento\Catalog\Api\Data\ProductRenderInterface;
12+
use Magento\Catalog\Helper\Image as ImageHelper;
13+
use Magento\Catalog\Helper\ImageFactory;
1014
use Magento\Catalog\Model\Product;
11-
use Magento\Catalog\Api\Data\ProductInterface;
1215
use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image;
1316
use Magento\Framework\View\DesignInterface;
17+
use Magento\Framework\View\DesignLoader;
1418
use Magento\Store\Model\StoreManagerInterface;
15-
use Magento\Catalog\Helper\ImageFactory;
16-
use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
17-
use Magento\Catalog\Helper\Image as ImageHelper;
1819

1920
/**
2021
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -42,8 +43,21 @@ class ImageTest extends \PHPUnit\Framework\TestCase
4243
/** @var \Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
4344
private $imageInterfaceFactory;
4445

46+
/** @var DesignLoader|\PHPUnit_Framework_MockObject_MockObject */
47+
private $designLoader;
48+
49+
/**
50+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
51+
*/
52+
protected $objectManager;
53+
54+
/**
55+
* @inheritdoc
56+
*/
4557
public function setUp()
4658
{
59+
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
60+
4761
$this->imageFactory = $this->getMockBuilder(ImageFactory::class)
4862
->disableOriginalConstructor()
4963
->getMock();
@@ -60,14 +74,21 @@ public function setUp()
6074
->getMock();
6175
$this->storeManager = $this->createMock(StoreManagerInterface::class);
6276
$this->design = $this->createMock(DesignInterface::class);
63-
$this->model = new Image(
64-
$this->imageFactory,
65-
$this->state,
66-
$this->storeManager,
67-
$this->design,
68-
$this->imageInterfaceFactory,
69-
$this->imageCodes
70-
);
77+
$this->designLoader = $this->createMock(DesignLoader::class);
78+
79+
$this->model = $this->objectManager
80+
->getObject(
81+
Image::class,
82+
[
83+
'imageFactory' => $this->imageFactory,
84+
'state' => $this->state,
85+
'storeManager' => $this->storeManager,
86+
'design' => $this->design,
87+
'imageRenderInfoFactory' => $this->imageInterfaceFactory,
88+
'imageCodes' => $this->imageCodes,
89+
'designLoader' => $this->designLoader,
90+
]
91+
);
7192
}
7293

7394
public function testGet()
@@ -165,6 +186,7 @@ public function testEmulateImageCreating()
165186
$imageMock->expects($this->once())
166187
->method('setUrl')
167188
->with('url');
189+
$this->designLoader->expects($this->once())->method('load');
168190

169191
$this->assertEquals(
170192
$imageHelperMock,

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
}
4646

4747
/**
48-
* {@inheritdoc}
48+
* @inheritdoc
4949
* @since 101.1.0
5050
*/
5151
public function modifyData(array $data)
@@ -54,8 +54,11 @@ public function modifyData(array $data)
5454
}
5555

5656
/**
57-
* {@inheritdoc}
57+
* Add tier price info to meta array.
58+
*
5859
* @since 101.1.0
60+
* @param array $meta
61+
* @return array
5962
*/
6063
public function modifyMeta(array $meta)
6164
{
@@ -150,8 +153,8 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
150153
'dataType' => Price::NAME,
151154
'addbefore' => '%',
152155
'validation' => [
153-
'validate-number' => true,
154-
'less-than-equals-to' => 100
156+
'required-entry' => true,
157+
'validate-positive-percent-decimal' => true,
155158
],
156159
'visible' => $firstOption
157160
&& $firstOption['value'] == ProductPriceOptionsInterface::VALUE_PERCENT,

app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
use Magento\Framework\View\DesignInterface;
1818
use Magento\Store\Model\StoreManager;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\Framework\View\DesignLoader;
2021

2122
/**
2223
* Collect enough information about image rendering on front
2324
* If you want to add new image, that should render on front you need
2425
* to configure this class in di.xml
2526
*
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628
*/
2729
class Image implements ProductRenderCollectorInterface
2830
{
@@ -59,6 +61,11 @@ class Image implements ProductRenderCollectorInterface
5961
*/
6062
private $imageRenderInfoFactory;
6163

64+
/**
65+
* @var DesignLoader
66+
*/
67+
private $designLoader;
68+
6269
/**
6370
* Image constructor.
6471
* @param ImageFactory $imageFactory
@@ -67,21 +74,25 @@ class Image implements ProductRenderCollectorInterface
6774
* @param DesignInterface $design
6875
* @param ImageInterfaceFactory $imageRenderInfoFactory
6976
* @param array $imageCodes
77+
* @param DesignLoader|null $designLoader
7078
*/
7179
public function __construct(
7280
ImageFactory $imageFactory,
7381
State $state,
7482
StoreManagerInterface $storeManager,
7583
DesignInterface $design,
7684
ImageInterfaceFactory $imageRenderInfoFactory,
77-
array $imageCodes = []
85+
array $imageCodes = [],
86+
DesignLoader $designLoader = null
7887
) {
7988
$this->imageFactory = $imageFactory;
8089
$this->imageCodes = $imageCodes;
8190
$this->state = $state;
8291
$this->storeManager = $storeManager;
8392
$this->design = $design;
8493
$this->imageRenderInfoFactory = $imageRenderInfoFactory;
94+
$this->designLoader = $designLoader ?: \Magento\Framework\App\ObjectManager::getInstance()
95+
->get(DesignLoader::class);
8596
}
8697

8798
/**
@@ -124,6 +135,8 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
124135
}
125136

126137
/**
138+
* Callback for emulating image creation.
139+
*
127140
* Callback in which we emulate initialize default design theme, depends on current store, be settings store id
128141
* from render info
129142
*
@@ -136,7 +149,7 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
136149
public function emulateImageCreating(ProductInterface $product, $imageCode, $storeId, ImageInterface $image)
137150
{
138151
$this->storeManager->setCurrentStore($storeId);
139-
$this->design->setDefaultDesignTheme();
152+
$this->designLoader->load();
140153

141154
$imageHelper = $this->imageFactory->create();
142155
$imageHelper->init($product, $imageCode);

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ protected function _saveProductCategories(array $categoriesData)
13721372
$delProductId[] = $productId;
13731373

13741374
foreach (array_keys($categories) as $categoryId) {
1375-
$categoriesIn[] = ['product_id' => $productId, 'category_id' => $categoryId, 'position' => 1];
1375+
$categoriesIn[] = ['product_id' => $productId, 'category_id' => $categoryId, 'position' => 0];
13761376
}
13771377
}
13781378
if (Import::BEHAVIOR_APPEND != $this->getBehavior()) {
@@ -1735,6 +1735,7 @@ protected function _saveProducts()
17351735
if ($uploadedFile) {
17361736
$uploadedImages[$columnImage] = $uploadedFile;
17371737
} else {
1738+
unset($rowData[$column]);
17381739
$this->addRowError(
17391740
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
17401741
$rowNum,

0 commit comments

Comments
 (0)