Skip to content

Commit 7b9aeef

Browse files
author
Alexander Akimov
authored
Merge pull request #2083 from magento-tsg/2.1-develop-pr46
[TSG] Backporting for 2.1 (pr46) (2.1.13)
2 parents 84f32b9 + f5f33fe commit 7b9aeef

File tree

31 files changed

+722
-264
lines changed

31 files changed

+722
-264
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ protected function _prepareTierPriceIndex($entityIds = null)
491491
null
492492
)->join(
493493
['e' => $this->getTable('catalog_product_entity')],
494-
"i.entity_id=e.$linkField",
494+
"i.entity_id=e.entity_id",
495495
[]
496496
)->where(
497497
'e.type_id=?',
@@ -502,7 +502,7 @@ protected function _prepareTierPriceIndex($entityIds = null)
502502

503503
$select = $connection->select()->from(
504504
['tp' => $this->getTable('catalog_product_entity_tier_price')],
505-
[$linkField]
505+
['e.entity_id']
506506
)->join(
507507
['e' => $this->getTable('catalog_product_entity')],
508508
"tp.{$linkField} = e.{$linkField}",
@@ -523,11 +523,11 @@ protected function _prepareTierPriceIndex($entityIds = null)
523523
)->columns(
524524
new \Zend_Db_Expr('MIN(tp.value)')
525525
)->group(
526-
["tp.{$linkField}", 'cg.customer_group_id', 'cw.website_id']
526+
['e.entity_id', 'cg.customer_group_id', 'cw.website_id']
527527
);
528528

529529
if (!empty($entityIds)) {
530-
$select->where("tp.{$linkField} IN(?)", $entityIds);
530+
$select->where('e.entity_id IN(?)', $entityIds);
531531
}
532532

533533
$query = $select->insertFromSelect($this->_getTierPriceIndexTable());

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\CatalogWidget\Block\Product;
108

119
use Magento\Framework\DataObject\IdentityInterface;
1210
use Magento\Widget\Block\BlockInterface;
11+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1312

1413
/**
1514
* Catalog Products List widget block
@@ -81,6 +80,11 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
8180
*/
8281
protected $conditionsHelper;
8382

83+
/**
84+
* @var PriceCurrencyInterface
85+
*/
86+
private $priceCurrency;
87+
8488
/**
8589
* @param \Magento\Catalog\Block\Product\Context $context
8690
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
@@ -90,6 +94,7 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
9094
* @param \Magento\CatalogWidget\Model\Rule $rule
9195
* @param \Magento\Widget\Helper\Conditions $conditionsHelper
9296
* @param array $data
97+
* @param PriceCurrencyInterface|null $priceCurrency
9398
*/
9499
public function __construct(
95100
\Magento\Catalog\Block\Product\Context $context,
@@ -99,14 +104,17 @@ public function __construct(
99104
\Magento\Rule\Model\Condition\Sql\Builder $sqlBuilder,
100105
\Magento\CatalogWidget\Model\Rule $rule,
101106
\Magento\Widget\Helper\Conditions $conditionsHelper,
102-
array $data = []
107+
array $data = [],
108+
PriceCurrencyInterface $priceCurrency = null
103109
) {
104110
$this->productCollectionFactory = $productCollectionFactory;
105111
$this->catalogProductVisibility = $catalogProductVisibility;
106112
$this->httpContext = $httpContext;
107113
$this->sqlBuilder = $sqlBuilder;
108114
$this->rule = $rule;
109115
$this->conditionsHelper = $conditionsHelper;
116+
$this->priceCurrency = $priceCurrency
117+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(PriceCurrencyInterface::class);
110118
parent::__construct(
111119
$context,
112120
$data
@@ -144,6 +152,7 @@ public function getCacheKeyInfo()
144152

145153
return [
146154
'CATALOG_PRODUCTS_LIST_WIDGET',
155+
$this->priceCurrency->getCurrencySymbol(),
147156
$this->_storeManager->getStore()->getId(),
148157
$this->_design->getDesignTheme()->getId(),
149158
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1212
use Magento\Catalog\Model\Product\Visibility;
13+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1314

1415
/**
15-
* Class ProductsListTest
16+
* Test for \Magento\CatalogWidget\Block\Product\ProductsList.
1617
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1718
*/
1819
class ProductsListTest extends \PHPUnit_Framework_TestCase
@@ -72,26 +73,32 @@ class ProductsListTest extends \PHPUnit_Framework_TestCase
7273
*/
7374
protected $layout;
7475

76+
/**
77+
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
78+
*/
79+
private $priceCurrency;
80+
7581
protected function setUp()
7682
{
83+
$this->priceCurrency = $this->getMock(PriceCurrencyInterface::class);
7784
$this->collectionFactory =
78-
$this->getMockBuilder('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory')
85+
$this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
7986
->setMethods(['create'])
8087
->disableOriginalConstructor()->getMock();
81-
$this->visibility = $this->getMockBuilder('Magento\Catalog\Model\Product\Visibility')
88+
$this->visibility = $this->getMockBuilder(\Magento\Catalog\Model\Product\Visibility::class)
8289
->setMethods(['getVisibleInCatalogIds'])
8390
->disableOriginalConstructor()
8491
->getMock();
85-
$this->httpContext = $this->getMock('Magento\Framework\App\Http\Context');
86-
$this->builder = $this->getMock('Magento\Rule\Model\Condition\Sql\Builder', [], [], '', false);
87-
$this->rule = $this->getMock('Magento\CatalogWidget\Model\Rule', [], [], '', false);
88-
$this->widgetConditionsHelper = $this->getMock('Magento\Widget\Helper\Conditions');
89-
$this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface');
90-
$this->design = $this->getMock('\Magento\Framework\View\DesignInterface');
92+
$this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class);
93+
$this->builder = $this->getMock(\Magento\Rule\Model\Condition\Sql\Builder::class, [], [], '', false);
94+
$this->rule = $this->getMock(\Magento\CatalogWidget\Model\Rule::class, [], [], '', false);
95+
$this->widgetConditionsHelper = $this->getMock(\Magento\Widget\Helper\Conditions::class);
96+
$this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
97+
$this->design = $this->getMock(\Magento\Framework\View\DesignInterface::class);
9198

9299
$objectManagerHelper = new ObjectManagerHelper($this);
93100
$arguments = $objectManagerHelper->getConstructArguments(
94-
'Magento\CatalogWidget\Block\Product\ProductsList',
101+
\Magento\CatalogWidget\Block\Product\ProductsList::class,
95102
[
96103
'productCollectionFactory' => $this->collectionFactory,
97104
'catalogProductVisibility' => $this->visibility,
@@ -100,59 +107,60 @@ protected function setUp()
100107
'rule' => $this->rule,
101108
'conditionsHelper' => $this->widgetConditionsHelper,
102109
'storeManager' => $this->storeManager,
103-
'design' => $this->design
110+
'design' => $this->design,
111+
'priceCurrency' => $this->priceCurrency,
104112
]
105113
);
106114
$this->request = $arguments['context']->getRequest();
107115
$this->layout = $arguments['context']->getLayout();
108116

109117
$this->productsList = $objectManagerHelper->getObject(
110-
'Magento\CatalogWidget\Block\Product\ProductsList',
118+
\Magento\CatalogWidget\Block\Product\ProductsList::class,
111119
$arguments
112120
);
113121
}
114122

115123
public function testGetCacheKeyInfo()
116124
{
117-
$store = $this->getMockBuilder('\Magento\Store\Model\Store')
125+
$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
118126
->disableOriginalConstructor()->setMethods(['getId'])->getMock();
119127
$store->expects($this->once())->method('getId')->willReturn(1);
120128
$this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
121129

122-
$theme = $this->getMock('\Magento\Framework\View\Design\ThemeInterface');
130+
$theme = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class);
123131
$theme->expects($this->once())->method('getId')->willReturn('blank');
124132
$this->design->expects($this->once())->method('getDesignTheme')->willReturn($theme);
125133

126134
$this->httpContext->expects($this->once())->method('getValue')->willReturn('context_group');
127135
$this->productsList->setData('conditions', 'some_serialized_conditions');
128-
129136
$this->productsList->setData('page_var_name', 'page_number');
130137
$this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1);
131-
132138
$this->request->expects($this->once())->method('getParams')->willReturn('request_params');
139+
$this->priceCurrency->expects($this->once())->method('getCurrencySymbol')->willReturn('$');
133140

134141
$cacheKey = [
135142
'CATALOG_PRODUCTS_LIST_WIDGET',
143+
'$',
136144
1,
137145
'blank',
138146
'context_group',
139147
1,
140148
5,
141149
'some_serialized_conditions',
142-
serialize('request_params')
150+
serialize('request_params'),
143151
];
144152
$this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo());
145153
}
146154

147155
public function testGetProductPriceHtml()
148156
{
149-
$product = $this->getMockBuilder('Magento\Catalog\Model\Product')
157+
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
150158
->setMethods(['getId'])
151159
->disableOriginalConstructor()
152160
->getMock();
153161
$product->expects($this->once())->method('getId')->willReturn(1);
154162

155-
$priceRenderer = $this->getMockBuilder('\Magento\Framework\Pricing\Render')
163+
$priceRenderer = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class)
156164
->setMethods(['render'])
157165
->disableOriginalConstructor()
158166
->getMock();
@@ -173,7 +181,7 @@ public function testGetProductPriceHtml()
173181
\Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
174182
[
175183
'include_container' => false,
176-
'display_minimal_price' => false
184+
'display_minimal_price' => false,
177185
]
178186
));
179187
}
@@ -185,7 +193,7 @@ public function testGetPagerHtmlEmpty()
185193

186194
public function testGetPagerHtml()
187195
{
188-
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection')
196+
$collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
189197
->setMethods(['getSize'])
190198
->disableOriginalConstructor()
191199
->getMock();
@@ -195,7 +203,7 @@ public function testGetPagerHtml()
195203
$this->productsList->setData('products_per_page', 2);
196204
$this->productsList->setData('product_collection', $collection);
197205

198-
$pagerBlock = $this->getMockBuilder('Magento\Catalog\Block\Product\Widget\Html\Pager')
206+
$pagerBlock = $this->getMockBuilder(\Magento\Catalog\Block\Product\Widget\Html\Pager::class)
199207
->setMethods([
200208
'toHtml',
201209
'setUseContainer',
@@ -205,7 +213,9 @@ public function testGetPagerHtml()
205213
'setLimit',
206214
'setTotalLimit',
207215
'setCollection',
208-
])->disableOriginalConstructor()->getMock();
216+
])
217+
->disableOriginalConstructor()
218+
->getMock();
209219

210220
$pagerBlock->expects($this->once())->method('setUseContainer')->willReturnSelf();
211221
$pagerBlock->expects($this->once())->method('setShowAmounts')->willReturnSelf();
@@ -233,7 +243,7 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
233243
{
234244
$this->visibility->expects($this->once())->method('getVisibleInCatalogIds')
235245
->willReturn([Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_BOTH]);
236-
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection')
246+
$collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
237247
->setMethods([
238248
'setVisibility',
239249
'addMinimalPrice',
@@ -322,14 +332,15 @@ public function testShowPager()
322332

323333
public function testGetIdentities()
324334
{
325-
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection')
335+
$collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
326336
->setMethods([
327337
'addAttributeToSelect',
328338
'getIterator',
329-
])->disableOriginalConstructor()
339+
])
340+
->disableOriginalConstructor()
330341
->getMock();
331342

332-
$product = $this->getMock('Magento\Framework\DataObject\IdentityInterface', ['getIdentities']);
343+
$product = $this->getMock(\Magento\Framework\DataObject\IdentityInterface::class, ['getIdentities']);
333344
$notProduct = $this->getMock('NotProduct', ['getIdentities']);
334345
$product->expects($this->once())->method('getIdentities')->willReturn(['product_identity']);
335346
$collection->expects($this->once())->method('getIterator')->willReturn(
@@ -349,7 +360,7 @@ public function testGetIdentities()
349360
*/
350361
private function getConditionsForCollection($collection)
351362
{
352-
$conditions = $this->getMockBuilder('\Magento\Rule\Model\Condition\Combine')
363+
$conditions = $this->getMockBuilder(\Magento\Rule\Model\Condition\Combine::class)
353364
->setMethods(['collectValidatedAttributes'])
354365
->disableOriginalConstructor()
355366
->getMock();
@@ -359,6 +370,7 @@ private function getConditionsForCollection($collection)
359370

360371
$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
361372
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);
373+
362374
return $conditions;
363375
}
364376

app/code/Magento/Checkout/Helper/Data.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one
305305
'items' => nl2br($items),
306306
'total' => $total,
307307
]
308+
)->setScopeId(
309+
$checkout->getStoreId()
308310
)->setFrom(
309311
$this->scopeConfig->getValue(
310312
'checkout/payment_failed/identity',

0 commit comments

Comments
 (0)