Skip to content

Commit 4bb5467

Browse files
authored
Merge pull request #411 from magento-nord/NORD-PR
NORD-PR#7
2 parents fd12fa9 + e0d240f commit 4bb5467

File tree

8 files changed

+136
-12
lines changed

8 files changed

+136
-12
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ public function getIdentities()
22742274
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
22752275
}
22762276
}
2277-
2277+
22782278
if (($this->getOrigData('status') != $this->getData('status')) || $this->isStockStatusChanged()) {
22792279
foreach ($this->getCategoryIds() as $categoryId) {
22802280
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
@@ -2289,7 +2289,7 @@ public function getIdentities()
22892289

22902290
/**
22912291
* Check whether stock status changed
2292-
*
2292+
*
22932293
* @return bool
22942294
*/
22952295
private function isStockStatusChanged()
@@ -2307,7 +2307,7 @@ private function isStockStatusChanged()
23072307
&& ($stockItem->getIsInStock() != $stockData['is_in_stock'])
23082308
);
23092309
}
2310-
2310+
23112311
/**
23122312
* Reload PriceInfo object
23132313
*

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

Lines changed: 22 additions & 2 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
@@ -144,6 +148,7 @@ public function getCacheKeyInfo()
144148

145149
return [
146150
'CATALOG_PRODUCTS_LIST_WIDGET',
151+
$this->getPriceCurrency()->getCurrencySymbol(),
147152
$this->_storeManager->getStore()->getId(),
148153
$this->_design->getDesignTheme()->getId(),
149154
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
@@ -351,4 +356,19 @@ public function getTitle()
351356
{
352357
return $this->getData('title');
353358
}
359+
360+
/**
361+
* @return PriceCurrencyInterface
362+
*
363+
* @deprecated
364+
*/
365+
private function getPriceCurrency()
366+
{
367+
if ($this->priceCurrency === null) {
368+
$this->priceCurrency = \Magento\Framework\App\ObjectManager::getInstance()
369+
->get(PriceCurrencyInterface::class);
370+
}
371+
return $this->priceCurrency;
372+
373+
}
354374
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
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
/**
1516
* Class ProductsListTest
@@ -72,6 +73,11 @@ 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
{
7783
$this->collectionFactory =
@@ -105,11 +111,13 @@ protected function setUp()
105111
);
106112
$this->request = $arguments['context']->getRequest();
107113
$this->layout = $arguments['context']->getLayout();
114+
$this->priceCurrency = $this->getMock(PriceCurrencyInterface::class);
108115

109116
$this->productsList = $objectManagerHelper->getObject(
110117
\Magento\CatalogWidget\Block\Product\ProductsList::class,
111118
$arguments
112119
);
120+
$objectManagerHelper->setBackwardCompatibleProperty($this->productsList, 'priceCurrency', $this->priceCurrency);
113121
}
114122

115123
public function testGetCacheKeyInfo()
@@ -130,9 +138,11 @@ public function testGetCacheKeyInfo()
130138
$this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1);
131139

132140
$this->request->expects($this->once())->method('getParams')->willReturn('request_params');
141+
$this->priceCurrency->expects($this->once())->method('getCurrencySymbol')->willReturn('$');
133142

134143
$cacheKey = [
135144
'CATALOG_PRODUCTS_LIST_WIDGET',
145+
'$',
136146
1,
137147
'blank',
138148
'context_group',

app/code/Magento/ConfigurableProduct/Model/LinkManagement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function addChild($sku, $childSku)
103103
}
104104

105105
$childrenIds[] = $child->getId();
106-
$product->setAssociatedProductIds($childrenIds);
106+
$product->getExtensionAttributes()->setConfigurableProductLinks($childrenIds);
107107
$product->save();
108108
return true;
109109
}
@@ -132,7 +132,7 @@ public function removeChild($sku, $childSku)
132132
if (count($options) == count($ids)) {
133133
throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
134134
}
135-
$product->addData(['associated_product_ids' => $ids]);
135+
$product->getExtensionAttributes()->setConfigurableProductLinks($ids);
136136
$product->save();
137137
return true;
138138
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\ConfigurableProduct\Test\Unit\Model;
88

99
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
10+
use Magento\ConfigurableProduct\Test\Unit\Model\Product\ProductExtensionAttributes;
1011

1112
/**
1213
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -162,7 +163,15 @@ public function testAddChild()
162163
->will(
163164
$this->returnValue([0 => [1, 2, 3]])
164165
);
165-
$configurable->expects($this->once())->method('__call')->with('setAssociatedProductIds', [[1, 2, 3, 999]]);
166+
167+
$extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class)
168+
->setMethods(['setConfigurableProductLinks'])
169+
->disableOriginalConstructor()
170+
->getMockForAbstractClass();
171+
172+
$configurable->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
173+
$extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf();
174+
166175
$configurable->expects($this->once())->method('save');
167176

168177
$this->assertTrue(true, $this->object->addChild($productSku, $childSku));
@@ -206,7 +215,7 @@ public function testRemoveChild()
206215
$childSku = 'simple_10';
207216

208217
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
209-
->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup'])
218+
->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup', 'getExtensionAttributes'])
210219
->disableOriginalConstructor()
211220
->getMock();
212221

@@ -234,7 +243,14 @@ public function testRemoveChild()
234243
$productType->expects($this->once())->method('getUsedProducts')
235244
->will($this->returnValue([$option]));
236245

237-
$product->expects($this->once())->method('addData')->with(['associated_product_ids' => []]);
246+
$extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class)
247+
->setMethods(['setConfigurableProductLinks'])
248+
->disableOriginalConstructor()
249+
->getMockForAbstractClass();
250+
251+
$product->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
252+
$extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf();
253+
238254
$product->expects($this->once())->method('save');
239255
$this->assertTrue($this->object->removeChild($productSku, $childSku));
240256
}

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ protected function prepareVariations()
284284
'sku' => $product->getSku(),
285285
'name' => $product->getName(),
286286
'qty' => $this->getProductStockQty($product),
287-
'price' => $currency->toCurrency(sprintf("%f", $price), ['display' => false]),
287+
'price' => $price,
288288
'price_string' => $currency->toCurrency(sprintf("%f", $price)),
289289
'price_currency' => $this->locator->getStore()->getBaseCurrency()->getCurrencySymbol(),
290290
'configurable_attribute' => $this->getJsonConfigurableAttributes($variationOptions),

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ define([
432432

433433
for (t = 0; t < thumbs.length; t++) {
434434
this._setThumbsIcon(thumbs.eq(t), t);
435-
this._checkForVideo(e, fotorama, t);
435+
this._checkForVideo(e, fotorama, t + 1);
436436
}
437437

438438
this.fotoramaItem.on('fotorama:showend', $.proxy(function (evt, fotoramaData) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\Data;
7+
8+
class AssociatedProductsTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \Magento\Framework\ObjectManagerInterface $objectManager
12+
*/
13+
private $objectManager;
14+
15+
/**
16+
* @var \Magento\Framework\Registry $registry
17+
*/
18+
private $registry;
19+
20+
public function setUp()
21+
{
22+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
23+
$this->registry = $this->objectManager->get(\Magento\Framework\Registry::class);
24+
25+
}
26+
27+
/**
28+
* @dataProvider getProductMatrixDataProvider
29+
* @param string $interfaceLocale
30+
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
31+
* @magentoAppArea adminhtml
32+
*/
33+
public function testGetProductMatrix($interfaceLocale)
34+
{
35+
$productSku = 'configurable';
36+
$associatedProductsData = [
37+
[10 => '10.000'],
38+
[20 => '20.000']
39+
];
40+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
41+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
42+
$this->registry->register('current_product', $productRepository->get($productSku));
43+
/** @var $store \Magento\Store\Model\Store */
44+
$store = $this->objectManager->create(\Magento\Store\Model\Store::class);
45+
$store->load('admin');
46+
$this->registry->register('current_store', $store);
47+
/** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject $localeResolver */
48+
$localeResolver = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class)
49+
->setMethods(['getLocale'])
50+
->getMockForAbstractClass();
51+
$localeResolver->expects($this->any())->method('getLocale')->willReturn($interfaceLocale);
52+
$localeCurrency = $this->objectManager->create(
53+
\Magento\Framework\Locale\CurrencyInterface::class,
54+
['localeResolver' => $localeResolver]
55+
);
56+
$associatedProducts = $this->objectManager->create(
57+
AssociatedProducts::class,
58+
['localeCurrency' => $localeCurrency]
59+
);
60+
foreach ($associatedProducts->getProductMatrix() as $productMatrixId => $productMatrixData) {
61+
$this->assertEquals(
62+
$associatedProductsData[$productMatrixId][$productMatrixData['id']],
63+
$productMatrixData['price']
64+
);
65+
}
66+
}
67+
68+
/**
69+
* @return array
70+
*/
71+
public function getProductMatrixDataProvider()
72+
{
73+
return [
74+
['en_US'],
75+
['zh_Hans_CN']
76+
];
77+
}
78+
}

0 commit comments

Comments
 (0)