Skip to content

Commit b500a76

Browse files
committed
MAGETWO-60246: [Backport] - [Github]Magento 2.1.1 Problem with change currency #6746 - for 2.1.x
1 parent 357320c commit b500a76

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ public function getDataSet(
9696
$currencyRate = $store->getCurrentCurrencyRate() ? : 1;
9797
$valueExpr = new \Zend_Db_Expr('main_table.min_price * ' . $currencyRate);
9898
$table = $this->resource->getTableName('catalog_product_index_price');
99-
$select->from(['main_table' => $table], null)
100-
->columns([BucketInterface::FIELD_VALUE => $valueExpr])
99+
$select->from(['main_table' => $table], [BucketInterface::FIELD_VALUE => $valueExpr])
101100
->where('main_table.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
102101
->where('main_table.website_id = ?', $store->getWebsiteId());
103102
} else {
@@ -118,7 +117,7 @@ public function getDataSet(
118117
->where('stock_index.stock_status = ?', Stock::STOCK_IN_STOCK)
119118
->group(['main_table.entity_id', 'main_table.value']);
120119
$parentSelect = $this->getSelect();
121-
$parentSelect->from(['main_table' => $subSelect], ['main_table.value']);
120+
$parentSelect->from(['main_table' => $subSelect], [BucketInterface::FIELD_VALUE => 'main_table.value']);
122121
$select = $parentSelect;
123122
}
124123

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function getAggregation(
133133
) {
134134
$select = $this->dataProvider->getDataSet($bucket, $dimensions, $entityStorage->getSource());
135135
$columns = array_column($select->getPart(Select::COLUMNS), 1, 2);
136-
$valueColumn = (string) $columns['value'];
136+
$valueColumn = (string) $columns[BucketInterface::FIELD_VALUE];
137137
$select->reset(Select::COLUMNS);
138138
$rangeExpr = new \Zend_Db_Expr(
139139
$this->connection->getIfNullSql(

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ public function getCurrencyRate()
158158
{
159159
$rate = $this->_getData('currency_rate');
160160
if ($rate === null) {
161-
$rate = $this->_storeManager->getStore($this->getStoreId())
162-
->getCurrentCurrencyRate();
161+
$rate = $this->_storeManager->getStore()->getCurrentCurrencyRate();
163162
}
164163
if (!$rate) {
165164
$rate = 1;

app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/PriceTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ protected function setUp()
129129
->method('escapeHtml')
130130
->will($this->returnArgument(0));
131131

132+
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
133+
->setMethods(['getCurrentCurrencyRate'])
134+
->getMockForAbstractClass();
135+
$storeMock->expects($this->any())
136+
->method('getCurrentCurrencyRate')
137+
->willReturn(1);
138+
$storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
139+
->getMockForAbstractClass();
140+
$storeManagerMock->expects($this->any())
141+
->method('getStore')
142+
->willReturn($storeMock);
143+
132144
$this->attribute = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute')
133145
->disableOriginalConstructor()
134146
->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable'])
@@ -142,6 +154,7 @@ protected function setUp()
142154
'itemDataBuilder' => $this->itemDataBuilder,
143155
'filterItemFactory' => $this->filterItemFactory,
144156
'escaper' => $escaper,
157+
'storeManager' => $storeManagerMock,
145158
]
146159
);
147160
}

0 commit comments

Comments
 (0)