Skip to content

Commit 7f87c2e

Browse files
committed
Merge branch 'MAGETWO-69714' of github.com:magento-troll/magento2ce into PR_Troll
2 parents c2eb6ac + 5a6eb3a commit 7f87c2e

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,8 @@ protected function updateValues(array $valuesToUpdate, array $oldValues)
180180
{
181181
$isChanged = false;
182182
foreach ($valuesToUpdate as $key => $value) {
183-
$oldPrice = $this->prepareFloatValue($oldValues[$key]['price']);
184-
$newPrice = $this->prepareFloatValue($value['value']);
185-
$oldQty = $this->prepareFloatValue($oldValues[$key]['price_qty']);
186-
$newQty = $this->prepareFloatValue($value['qty']);
187-
$oldPercentageValue = $this->prepareFloatValue($this->getPercentage($oldValues[$key]));
188-
$newPercentageValue = $this->prepareFloatValue($this->getPercentage($value));
189-
if (($oldPrice !== $newPrice)
190-
|| ($oldQty !== $newQty)
191-
|| ($oldPercentageValue !== $newPercentageValue)
183+
if ($oldValues[$key]['price'] != $value['value']
184+
|| $this->getPercentage($oldValues[$key]) != $this->getPercentage($value)
192185
) {
193186
$price = new \Magento\Framework\DataObject(
194187
[
@@ -205,17 +198,6 @@ protected function updateValues(array $valuesToUpdate, array $oldValues)
205198
return $isChanged;
206199
}
207200

208-
/**
209-
* Prepare float value for comparison
210-
*
211-
* @param string|float|int $value
212-
* @return float
213-
*/
214-
private function prepareFloatValue($value)
215-
{
216-
return floatval(str_replace(',', '.', (string)$value));
217-
}
218-
219201
/**
220202
* Check whether price has percentage value.
221203
*

app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected function addNotGlobalAttribute(
222222
public function getMappedSqlField()
223223
{
224224
$result = '';
225-
if ($this->getAttribute() == 'category_ids') {
225+
if (in_array($this->getAttribute(), ['category_ids', 'sku'])) {
226226
$result = parent::getMappedSqlField();
227227
} elseif (isset($this->joinedAttributes[$this->getAttribute()])) {
228228
$result = $this->joinedAttributes[$this->getAttribute()];

app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ protected function setUp()
3636
'',
3737
false
3838
);
39-
$eavConfig->expects($this->once())->method('getAttribute')->willReturn($this->attributeMock);
39+
$eavConfig->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock);
4040
$ruleMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false);
4141
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
4242
$storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class);
43-
$storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
43+
$storeManager->expects($this->any())->method('getStore')->willReturn($storeMock);
4444
$this->resourceMock = $this->getMock(
4545
\Magento\Indexer\Model\ResourceModel\FrontendResource::class,
4646
[],
@@ -49,8 +49,8 @@ protected function setUp()
4949
false
5050
);
5151
$productResource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false);
52-
$productResource->expects($this->once())->method('loadAllAttributes')->willReturnSelf();
53-
$productResource->expects($this->once())->method('getAttributesByCode')->willReturn([]);
52+
$productResource->expects($this->any())->method('loadAllAttributes')->willReturnSelf();
53+
$productResource->expects($this->any())->method('getAttributesByCode')->willReturn([]);
5454
$this->model = $objectManagerHelper->getObject(
5555
\Magento\CatalogWidget\Model\Rule\Condition\Product::class,
5656
[
@@ -88,4 +88,10 @@ public function testAddToCollection()
8888
$this->resourceMock->expects($this->once())->method('getMainTable')->willReturn('catalog_product_index_eav');
8989
$this->model->addToCollection($collectionMock);
9090
}
91+
92+
public function testGetMappedSqlFieldSku()
93+
{
94+
$this->model->setAttribute('sku');
95+
$this->assertEquals('e.sku', $this->model->getMappedSqlField());
96+
}
9197
}

dev/tests/integration/testsuite/Magento/CatalogWidget/Model/Rule/Condition/ProductTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,13 @@ public function testGetMappedSqlFieldCategoryIdsAttribute()
9494
$this->conditionProduct->setAttribute('category_ids');
9595
$this->assertEquals('e.entity_id', $this->conditionProduct->getMappedSqlField());
9696
}
97+
98+
/**
99+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
100+
*/
101+
public function testGetMappedSqlFieldSkuAttribute()
102+
{
103+
$this->conditionProduct->setAttribute('sku');
104+
$this->assertEquals('e.sku', $this->conditionProduct->getMappedSqlField());
105+
}
97106
}

0 commit comments

Comments
 (0)