Skip to content

Commit e6f56b1

Browse files
committed
Merge remote-tracking branch '37899/fix-new-widget' into community_prs_april
2 parents a6f9324 + 2b1ed87 commit e6f56b1

File tree

2 files changed

+17
-7
lines changed
  • app/code/Magento/Catalog/Block/Product/Widget
  • dev/tests/integration/testsuite/Magento/Catalog/Block/Product

2 files changed

+17
-7
lines changed

app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Block\Product\Widget;
77

8+
use Magento\Framework\App\Http\Context as HttpContext;
9+
810
/**
911
* New products widget
1012
*/
@@ -13,29 +15,29 @@ class NewWidget extends \Magento\Catalog\Block\Product\NewProduct implements \Ma
1315
/**
1416
* Display products type - all products
1517
*/
16-
const DISPLAY_TYPE_ALL_PRODUCTS = 'all_products';
18+
public const DISPLAY_TYPE_ALL_PRODUCTS = 'all_products';
1719

1820
/**
1921
* Display products type - new products
2022
*/
21-
const DISPLAY_TYPE_NEW_PRODUCTS = 'new_products';
23+
public const DISPLAY_TYPE_NEW_PRODUCTS = 'new_products';
2224

2325
/**
2426
* Default value whether show pager or not
2527
*/
26-
const DEFAULT_SHOW_PAGER = false;
28+
public const DEFAULT_SHOW_PAGER = false;
2729

2830
/**
2931
* Default value for products per page
3032
*/
31-
const DEFAULT_PRODUCTS_PER_PAGE = 5;
33+
public const DEFAULT_PRODUCTS_PER_PAGE = 5;
3234

3335
/**
3436
* Name of request parameter for page number value
3537
*
3638
* @deprecated
3739
*/
38-
const PAGE_VAR_NAME = 'np';
40+
public const PAGE_VAR_NAME = 'np';
3941

4042
/**
4143
* Instance of pager block
@@ -134,13 +136,15 @@ public function getCurrentPage()
134136
*/
135137
public function getCacheKeyInfo()
136138
{
139+
$store = $this->_storeManager->getStore();
137140
return array_merge(
138141
parent::getCacheKeyInfo(),
139142
[
140143
$this->getDisplayType(),
141144
$this->getProductsPerPage(),
142145
(int) $this->getRequest()->getParam($this->getData('page_var_name'), 1),
143-
$this->serializer->serialize($this->getRequest()->getParams())
146+
$this->serializer->serialize($this->getRequest()->getParams()),
147+
$this->httpContext->getValue(HttpContext::CONTEXT_CURRENCY) ?: $store->getDefaultCurrency()->getCode()
144148
]
145149
);
146150
}
@@ -268,7 +272,7 @@ public function getProductPriceHtml(
268272
? $arguments['display_minimal_price']
269273
: true;
270274

271-
/** @var \Magento\Framework\Pricing\Render $priceRender */
275+
/** @var \Magento\Framework\Pricing\Render $priceRender */
272276
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
273277

274278
$price = '';

dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,11 @@ public function testNewWidgetGetCacheKeyInfo()
136136

137137
$this->assertEquals('CATALOG_PRODUCT_NEW', $info[0]);
138138
$this->assertEquals(json_encode($requestParams), $info[8]);
139+
140+
$currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
141+
\Magento\Store\Model\StoreManagerInterface::class
142+
)->getStore();
143+
144+
$this->assertSame($currentStore->getDefaultCurrency()->getCode(), $info[9]);
139145
}
140146
}

0 commit comments

Comments
 (0)