Skip to content

Commit 8552357

Browse files
authored
Merge branch '2.4-develop' into MCP-1010
2 parents 14693cc + c3ad511 commit 8552357

File tree

107 files changed

+2846
-425
lines changed

Some content is hidden

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

107 files changed

+2846
-425
lines changed

app/code/Magento/Bundle/Test/Mftf/Test/AdminBundleProductPriceValidationErrorDisappearedAfterSwitchToDynamicPriceTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<argument name="price" value="test"/>
3535
</actionGroup>
3636
<actionGroup ref="AssertAdminValidationErrorAppearedForPriceFieldOnProductEditPageActionGroup" stepKey="assertVisibleError">
37-
<argument name="errorMessage" value="Please enter a number 0 or greater in this field."/>
37+
<argument name="errorMessage" value="Please enter a number 0 or greater, without comma in this field."/>
3838
</actionGroup>
3939
<actionGroup ref="AdminToggleSwitchDynamicPriceOnProductEditPageActionGroup" stepKey="enableDynamicPrice"/>
4040
<actionGroup ref="AssertAdminNoValidationErrorForPriceFieldOnProductEditPageActionGroup" stepKey="assertNotVisibleError"/>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ class Helper
121121
*/
122122
private $categoryLinkFactory;
123123

124+
/**
125+
* @var array
126+
*/
127+
private $productDataKeys = [
128+
'weight',
129+
'special_price',
130+
'cost',
131+
'country_of_manufacture',
132+
'description',
133+
'short_description',
134+
'meta_description',
135+
'meta_keyword',
136+
'meta_title',
137+
'page_layout',
138+
'custom_design',
139+
'gift_wrapping_price'
140+
];
141+
124142
/**
125143
* Constructor
126144
*
@@ -203,6 +221,12 @@ public function initializeFromData(Product $product, array $productData)
203221
$productData['product_has_weight'] = 0;
204222
}
205223

224+
foreach ($productData as $key => $value) {
225+
if (in_array($key, $this->productDataKeys) && $value === '') {
226+
$productData[$key] = null;
227+
}
228+
}
229+
206230
foreach (['category_ids', 'website_ids'] as $field) {
207231
if (!isset($productData[$field])) {
208232
$productData[$field] = [];

app/code/Magento/Catalog/Model/Indexer/Product/Eav/AbstractAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class AbstractAction
1717
/**
1818
* Config path for enable EAV indexer
1919
*/
20-
const ENABLE_EAV_INDEXER = 'catalog/search/enable_eav_indexer';
20+
public const ENABLE_EAV_INDEXER = 'catalog/search/enable_eav_indexer';
2121

2222
/**
2323
* EAV Indexers by type
@@ -142,7 +142,7 @@ protected function syncData($indexer, $destinationTable, $ids)
142142
$connection->beginTransaction();
143143
try {
144144
// remove old index
145-
$where = $connection->quoteInto('entity_id IN(?)', $ids);
145+
$where = $connection->quoteInto('entity_id IN (?)', $ids, 'INT');
146146
$connection->delete($destinationTable, $where);
147147
// insert new index
148148
$indexer->insertFromTable($indexer->getIdxTable(), $destinationTable);

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,8 @@
829829
<entity name="virtualProductCustomImportOptions" type="product">
830830
<data key="name" unique="suffix">VirtualProduct</data>
831831
<data key="sku" unique="suffix">virtual_sku</data>
832-
<data key="price">9,000.00</data>
832+
<data key="price">9000.00</data>
833+
<data key="formattedPrice">9,000.00</data>
833834
<data key="quantity">999</data>
834835
<data key="status">In Stock</data>
835836
<data key="visibility">Catalog, Search</data>
@@ -850,7 +851,8 @@
850851
<entity name="virtualProductOutOfStock" type="product">
851852
<data key="name" unique="suffix">VirtualProduct</data>
852853
<data key="sku" unique="suffix">virtual_sku</data>
853-
<data key="price">9,000.00</data>
854+
<data key="price">9000.00</data>
855+
<data key="formattedPrice">9,000.00</data>
854856
<data key="quantity">999</data>
855857
<data key="status">Out of Stock</data>
856858
<data key="visibility">Catalog, Search</data>

app/code/Magento/Catalog/Test/Mftf/Data/TierPriceData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<entity name="tierPriceHighCostSimpleProduct" type="data">
4646
<data key="website">All Websites [USD]</data>
4747
<data key="customer_group">ALL GROUPS</data>
48-
<data key="price">500,000.00</data>
48+
<data key="price">500000.00</data>
4949
<data key="qty">1</data>
5050
</entity>
5151
<entity name="tierProductPrice" type="catalogTierPrice">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCreateSimpleProductCommaSeparatedPriceTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Create a Simple Product via Admin"/>
14+
<title value="Admin should not be able to create a product with a comma separated price"/>
15+
<description value="Admin should not be able to create a product with a comma separated price"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="AC-2928"/>
18+
<useCaseId value="ACP2E-420"/>
19+
<group value="product"/>
20+
</annotations>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="goToCreateProduct"/>
23+
<actionGroup ref="FillMainProductFormByStringActionGroup" stepKey="fillPrice">
24+
<argument name="productName" value="{{SimpleProduct.name}}"/>
25+
<argument name="productSku" value="{{SimpleProduct.sku}}"/>
26+
<argument name="productPrice" value="33,444"/>
27+
<argument name="productQuantity" value="{{SimpleProduct.quantity}}"/>
28+
<argument name="productStatus" value="{{SimpleProduct.status}}"/>
29+
<argument name="productWeight" value="{{SimpleProduct.weight}}"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSave"/>
32+
<actionGroup ref="AssertAdminValidationErrorAppearedForPriceFieldOnProductEditPageActionGroup" stepKey="seePriceValidationError">
33+
<argument name="errorMessage" value="Please enter a number 0 or greater, without comma in this field."/>
34+
</actionGroup>
35+
</test>
36+
</tests>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</assertEquals>
9898
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="productPriceAmount"/>
9999
<assertEquals stepKey="assertOldPriceTextOnProductPage">
100-
<expectedResult type="string">${{virtualProductOutOfStock.price}}</expectedResult>
100+
<expectedResult type="string">${{virtualProductOutOfStock.formattedPrice}}</expectedResult>
101101
<actualResult type="variable">productPriceAmount</actualResult>
102102
</assertEquals>
103103
</test>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
</assertEquals>
151151
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="productPriceAmount"/>
152152
<assertEquals stepKey="assertOldPriceTextOnProductPage">
153-
<expectedResult type="string">${{virtualProductCustomImportOptions.price}}</expectedResult>
153+
<expectedResult type="string">${{virtualProductCustomImportOptions.formattedPrice}}</expectedResult>
154154
<actualResult type="variable">productPriceAmount</actualResult>
155155
</assertEquals>
156156

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php

Lines changed: 102 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,122 @@
88
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Action;
99

1010
use Magento\Catalog\Model\Indexer\Product\Eav\Action\Row;
11-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal;
12+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory;
13+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source;
14+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
16+
use Magento\Framework\DB\Adapter\AdapterInterface;
17+
use Magento\Framework\Exception\InputException;
18+
use Magento\Store\Model\ScopeInterface;
19+
use PHPUnit\Framework\MockObject\MockObject;
1220
use PHPUnit\Framework\TestCase;
1321

1422
class RowTest extends TestCase
1523
{
24+
/**
25+
* @var DecimalFactory|MockObject
26+
*/
27+
private $eavDecimalFactoryMock;
28+
29+
/**
30+
* @var SourceFactory|MockObject
31+
*/
32+
private $eavSourceFactoryMock;
33+
34+
/**
35+
* @var ScopeConfigInterface|MockObject
36+
*/
37+
private $scopeConfigMock;
38+
1639
/**
1740
* @var Row
1841
*/
19-
protected $_model;
42+
private $model;
2043

2144
protected function setUp(): void
2245
{
23-
$objectManager = new ObjectManager($this);
24-
$this->_model = $objectManager->getObject(Row::class);
46+
$this->eavDecimalFactoryMock = $this->createMock(DecimalFactory::class);
47+
$this->eavSourceFactoryMock = $this->createMock(SourceFactory::class);
48+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
49+
$this->model = new Row(
50+
$this->eavDecimalFactoryMock,
51+
$this->eavSourceFactoryMock,
52+
$this->scopeConfigMock
53+
);
2554
}
2655

2756
public function testEmptyId()
2857
{
29-
$this->expectException('Magento\Framework\Exception\InputException');
58+
$this->expectException(InputException::class);
3059
$this->expectExceptionMessage('We can\'t rebuild the index for an undefined product.');
31-
$this->_model->execute(null);
60+
$this->model->execute(null);
61+
}
62+
63+
public function testExecute(): void
64+
{
65+
$this->scopeConfigMock->expects($this->once())
66+
->method('getValue')
67+
->with(Row::ENABLE_EAV_INDEXER, ScopeInterface::SCOPE_STORE)
68+
->willReturn(true);
69+
70+
$eavDecimalMock = $this->createMock(Decimal::class);
71+
$this->eavDecimalFactoryMock->expects($this->once())
72+
->method('create')
73+
->willReturn($eavDecimalMock);
74+
$eavSourceMock = $this->createMock(Source::class);
75+
$this->eavSourceFactoryMock->expects($this->once())
76+
->method('create')
77+
->willReturn($eavSourceMock);
78+
79+
foreach ([$eavDecimalMock, $eavSourceMock] as $indexerMock) {
80+
$indexerMock->expects($this->atLeastOnce())
81+
->method('getRelationsByChild')
82+
->with([15])
83+
->willReturn([]);
84+
$indexerMock->expects($this->atLeastOnce())
85+
->method('getRelationsByParent')
86+
->with([15])
87+
->willReturn([]);
88+
$indexerMock->expects($this->once())
89+
->method('reindexEntities')
90+
->with([15])
91+
->willReturnSelf();
92+
$mainTable = 'main_table_name';
93+
$indexerMock->expects($this->atLeastOnce())
94+
->method('getMainTable')
95+
->willReturn($mainTable);
96+
97+
$connectionMock = $this->createMock(AdapterInterface::class);
98+
$indexerMock->expects($this->atLeastOnce())
99+
->method('getConnection')
100+
->willReturn($connectionMock);
101+
$connectionMock->expects($this->once())
102+
->method('beginTransaction')
103+
->willReturnSelf();
104+
$connectionMock->expects($this->once())
105+
->method('quoteInto')
106+
->with('entity_id IN (?)', [15], 'INT')
107+
->willReturn('entity_id IN (15)');
108+
$connectionMock->expects($this->once())
109+
->method('delete')
110+
->with($mainTable, 'entity_id IN (15)')
111+
->willReturn(3);
112+
$idxTable = 'idx_table_name';
113+
$indexerMock->expects($this->atLeastOnce())
114+
->method('getIdxTable')
115+
->with()
116+
->willReturn($idxTable);
117+
$indexerMock->expects($this->once())
118+
->method('insertFromTable')
119+
->with($idxTable, $mainTable)
120+
->willReturnSelf();
121+
$connectionMock->expects($this->once())
122+
->method('commit')
123+
->willReturnSelf();
124+
}
125+
126+
$id = 15;
127+
$this->model->execute($id);
32128
}
33129
}

0 commit comments

Comments
 (0)