diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 6b5f45bdb4f13..49df6fd57c323 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -2274,7 +2274,7 @@ public function getIdentities() $identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId; } } - + if (($this->getOrigData('status') != $this->getData('status')) || $this->isStockStatusChanged()) { foreach ($this->getCategoryIds() as $categoryId) { $identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId; @@ -2289,7 +2289,7 @@ public function getIdentities() /** * Check whether stock status changed - * + * * @return bool */ private function isStockStatusChanged() @@ -2307,7 +2307,7 @@ private function isStockStatusChanged() && ($stockItem->getIsInStock() != $stockData['is_in_stock']) ); } - + /** * Reload PriceInfo object * diff --git a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php index a547fb862acac..0f665984b0e04 100644 --- a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php +++ b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php @@ -4,12 +4,11 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogWidget\Block\Product; use Magento\Framework\DataObject\IdentityInterface; use Magento\Widget\Block\BlockInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Catalog Products List widget block @@ -81,6 +80,11 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem */ protected $conditionsHelper; + /** + * @var PriceCurrencyInterface + */ + private $priceCurrency; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory @@ -144,6 +148,7 @@ public function getCacheKeyInfo() return [ 'CATALOG_PRODUCTS_LIST_WIDGET', + $this->getPriceCurrency()->getCurrencySymbol(), $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP), @@ -351,4 +356,19 @@ public function getTitle() { return $this->getData('title'); } + + /** + * @return PriceCurrencyInterface + * + * @deprecated + */ + private function getPriceCurrency() + { + if ($this->priceCurrency === null) { + $this->priceCurrency = \Magento\Framework\App\ObjectManager::getInstance() + ->get(PriceCurrencyInterface::class); + } + return $this->priceCurrency; + + } } diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php index fd4ae990a754d..c2410cea1d9bf 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php @@ -10,6 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Catalog\Model\Product\Visibility; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Class ProductsListTest @@ -72,6 +73,11 @@ class ProductsListTest extends \PHPUnit_Framework_TestCase */ protected $layout; + /** + * @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $priceCurrency; + protected function setUp() { $this->collectionFactory = @@ -105,11 +111,13 @@ protected function setUp() ); $this->request = $arguments['context']->getRequest(); $this->layout = $arguments['context']->getLayout(); + $this->priceCurrency = $this->getMock(PriceCurrencyInterface::class); $this->productsList = $objectManagerHelper->getObject( \Magento\CatalogWidget\Block\Product\ProductsList::class, $arguments ); + $objectManagerHelper->setBackwardCompatibleProperty($this->productsList, 'priceCurrency', $this->priceCurrency); } public function testGetCacheKeyInfo() @@ -130,9 +138,11 @@ public function testGetCacheKeyInfo() $this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1); $this->request->expects($this->once())->method('getParams')->willReturn('request_params'); + $this->priceCurrency->expects($this->once())->method('getCurrencySymbol')->willReturn('$'); $cacheKey = [ 'CATALOG_PRODUCTS_LIST_WIDGET', + '$', 1, 'blank', 'context_group', diff --git a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php index cd205746a9bce..0fdfbd3bfa172 100644 --- a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php +++ b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php @@ -103,7 +103,7 @@ public function addChild($sku, $childSku) } $childrenIds[] = $child->getId(); - $product->setAssociatedProductIds($childrenIds); + $product->getExtensionAttributes()->setConfigurableProductLinks($childrenIds); $product->save(); return true; } @@ -132,7 +132,7 @@ public function removeChild($sku, $childSku) if (count($options) == count($ids)) { throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } - $product->addData(['associated_product_ids' => $ids]); + $product->getExtensionAttributes()->setConfigurableProductLinks($ids); $product->save(); return true; } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php index 84d3ac72c187e..6b69888e6dd09 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php @@ -7,6 +7,7 @@ namespace Magento\ConfigurableProduct\Test\Unit\Model; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use Magento\ConfigurableProduct\Test\Unit\Model\Product\ProductExtensionAttributes; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -162,7 +163,15 @@ public function testAddChild() ->will( $this->returnValue([0 => [1, 2, 3]]) ); - $configurable->expects($this->once())->method('__call')->with('setAssociatedProductIds', [[1, 2, 3, 999]]); + + $extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class) + ->setMethods(['setConfigurableProductLinks']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $configurable->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes); + $extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf(); + $configurable->expects($this->once())->method('save'); $this->assertTrue(true, $this->object->addChild($productSku, $childSku)); @@ -206,7 +215,7 @@ public function testRemoveChild() $childSku = 'simple_10'; $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) - ->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup']) + ->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup', 'getExtensionAttributes']) ->disableOriginalConstructor() ->getMock(); @@ -234,7 +243,14 @@ public function testRemoveChild() $productType->expects($this->once())->method('getUsedProducts') ->will($this->returnValue([$option])); - $product->expects($this->once())->method('addData')->with(['associated_product_ids' => []]); + $extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class) + ->setMethods(['setConfigurableProductLinks']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $product->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes); + $extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf(); + $product->expects($this->once())->method('save'); $this->assertTrue($this->object->removeChild($productSku, $childSku)); } diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php index da7a0d7a3d9da..ac1b8b981ea3d 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php @@ -284,7 +284,7 @@ protected function prepareVariations() 'sku' => $product->getSku(), 'name' => $product->getName(), 'qty' => $this->getProductStockQty($product), - 'price' => $currency->toCurrency(sprintf("%f", $price), ['display' => false]), + 'price' => $price, 'price_string' => $currency->toCurrency(sprintf("%f", $price)), 'price_currency' => $this->locator->getStore()->getBaseCurrency()->getCurrencySymbol(), 'configurable_attribute' => $this->getJsonConfigurableAttributes($variationOptions), diff --git a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js index 0b149e37a0716..43a0292270a3f 100644 --- a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js +++ b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js @@ -432,7 +432,7 @@ define([ for (t = 0; t < thumbs.length; t++) { this._setThumbsIcon(thumbs.eq(t), t); - this._checkForVideo(e, fotorama, t); + this._checkForVideo(e, fotorama, t + 1); } this.fotoramaItem.on('fotorama:showend', $.proxy(function (evt, fotoramaData) { diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProductsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProductsTest.php new file mode 100644 index 0000000000000..0639c7353d55e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProductsTest.php @@ -0,0 +1,78 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->registry = $this->objectManager->get(\Magento\Framework\Registry::class); + + } + + /** + * @dataProvider getProductMatrixDataProvider + * @param string $interfaceLocale + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * @magentoAppArea adminhtml + */ + public function testGetProductMatrix($interfaceLocale) + { + $productSku = 'configurable'; + $associatedProductsData = [ + [10 => '10.000'], + [20 => '20.000'] + ]; + /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->registry->register('current_product', $productRepository->get($productSku)); + /** @var $store \Magento\Store\Model\Store */ + $store = $this->objectManager->create(\Magento\Store\Model\Store::class); + $store->load('admin'); + $this->registry->register('current_store', $store); + /** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject $localeResolver */ + $localeResolver = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) + ->setMethods(['getLocale']) + ->getMockForAbstractClass(); + $localeResolver->expects($this->any())->method('getLocale')->willReturn($interfaceLocale); + $localeCurrency = $this->objectManager->create( + \Magento\Framework\Locale\CurrencyInterface::class, + ['localeResolver' => $localeResolver] + ); + $associatedProducts = $this->objectManager->create( + AssociatedProducts::class, + ['localeCurrency' => $localeCurrency] + ); + foreach ($associatedProducts->getProductMatrix() as $productMatrixId => $productMatrixData) { + $this->assertEquals( + $associatedProductsData[$productMatrixId][$productMatrixData['id']], + $productMatrixData['price'] + ); + } + } + + /** + * @return array + */ + public function getProductMatrixDataProvider() + { + return [ + ['en_US'], + ['zh_Hans_CN'] + ]; + } +}