diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/catalog/product/edit/tab/attributes/extend.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/catalog/product/edit/tab/attributes/extend.phtml
index 2e38aae3d998d..ca26cfb192d4a 100644
--- a/app/code/Magento/Bundle/view/adminhtml/templates/catalog/product/edit/tab/attributes/extend.phtml
+++ b/app/code/Magento/Bundle/view/adminhtml/templates/catalog/product/edit/tab/attributes/extend.phtml
@@ -61,7 +61,9 @@ $isElementReadonly = $block->getElement()
&& !$block->getProduct()->isObjectNew())) { ?>
$('= /* @escapeNotVerified */ $switchAttributeCode?>').observe('change', = /* @escapeNotVerified */ $switchAttributeCode?>_change);
- = /* @escapeNotVerified */ $switchAttributeCode?>_change();
+ Event.observe(window, 'load', function(){
+ = /* @escapeNotVerified */ $switchAttributeCode?>_change();
+ });
});
diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
index 265a7df13725b..800b3e7e0ce16 100644
--- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
+++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
@@ -384,6 +384,9 @@ public function saveData()
public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
{
$rowData = array_merge($rowData, $this->transformBundleCustomAttributes($rowData));
+ if (isset($rowData['bundle_price_type']) && $rowData['bundle_price_type'] == 'dynamic') {
+ $rowData['price'] = isset($rowData['price']) && $rowData['price'] ? $rowData['price'] : '0.00';
+ }
return parent::isRowValid($rowData, $rowNum, $isNewProduct);
}
diff --git a/app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php b/app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php
index ac3ac5e92e00b..d9c0cf547368a 100644
--- a/app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php
+++ b/app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php
@@ -377,8 +377,8 @@ public function testIsRowValid()
{
$this->entityModel->expects($this->any())->method('getRowScope')->will($this->returnValue(-1));
$rowData = [
- 'price_type' => 'fixed',
- 'price_view' => 'bundle_price_view'
+ 'bundle_price_type' => 'dynamic',
+ 'bundle_price_view' => 'bundle_price_view'
];
$this->assertEquals($this->bundle->isRowValid($rowData, 0), true);
}
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
index f1251b95f9923..a5ff7b48d949c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
@@ -71,9 +71,11 @@ public function getAfterElementHtml()
$addJsObserver = false;
if ($attribute = $this->getEntityAttribute()) {
$store = $this->getStore($attribute);
- $html .= '' . $this->_localeCurrency->getCurrency(
- $store->getBaseCurrencyCode()
- )->getSymbol() . '';
+ if ($this->getType() !== 'hidden') {
+ $html .= ''
+ . $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode())->getSymbol()
+ . '';
+ }
if ($this->_taxData->priceIncludesTax($store)) {
if ($attribute->getAttributeCode() !== 'cost') {
$addJsObserver = true;
diff --git a/app/code/Magento/Catalog/Helper/Image.php b/app/code/Magento/Catalog/Helper/Image.php
index a847e8c42454a..834134d8719cb 100644
--- a/app/code/Magento/Catalog/Helper/Image.php
+++ b/app/code/Magento/Catalog/Helper/Image.php
@@ -176,8 +176,8 @@ public function init($product, $imageId, $attributes = [])
$this->_reset();
$this->attributes = array_merge(
- $attributes,
- $this->getConfigView()->getMediaAttributes('Magento_Catalog', self::MEDIA_TYPE_CONFIG_NODE, $imageId)
+ $this->getConfigView()->getMediaAttributes('Magento_Catalog', self::MEDIA_TYPE_CONFIG_NODE, $imageId),
+ $attributes
);
$this->setProduct($product);
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
index 927411629c942..3107396c561ad 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
@@ -418,10 +418,9 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
{
$error = false;
$rowScope = $this->_entityModel->getRowScope($rowData);
- if ((\Magento\CatalogImportExport\Model\Import\Product::SCOPE_NULL != $rowScope) &&
- !empty($rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_SKU])) {
-
-
+ if (\Magento\CatalogImportExport\Model\Import\Product::SCOPE_NULL != $rowScope
+ && !empty($rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_SKU])
+ ) {
foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
// check value for non-empty in the case of required attribute?
if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
@@ -437,9 +436,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
))
) {
$this->_entityModel->addRowError(
- // @codingStandardsIgnoreStart
- \Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
- // @codingStandardsIgnoreEnd
+ RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
$rowNum,
$attrCode
);
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php
index cee5e53e97978..961e5c2d3a1ca 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php
@@ -104,6 +104,8 @@ public function isRequiredAttributeValid($attrCode, array $attributeParams, arra
$doCheck = false;
if ($attrCode == Product::COL_SKU) {
$doCheck = true;
+ } elseif ($attrCode == 'price') {
+ $doCheck = false;
} elseif ($attributeParams['is_required'] && $this->getRowScope($rowData) == Product::SCOPE_DEFAULT
&& $this->context->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE
) {
@@ -124,7 +126,9 @@ public function isRequiredAttributeValid($attrCode, array $attributeParams, arra
public function isAttributeValid($attrCode, array $attrParams, array $rowData)
{
$this->_rowData = $rowData;
- if (!empty($attrParams['apply_to']) && !in_array($rowData['product_type'], $attrParams['apply_to'])) {
+ if (isset($rowData['product_type']) && !empty($attrParams['apply_to'])
+ && !in_array($rowData['product_type'], $attrParams['apply_to'])
+ ) {
return true;
}
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
index b7fd1e3604b67..104db2207b139 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
@@ -98,6 +98,7 @@ public function testAttributeValidation($behavior, $attrParams, $rowData, $isVal
/**
* @return array
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function attributeValidationProvider()
{
@@ -147,6 +148,13 @@ public function attributeValidationProvider()
['product_type' => 'any', 'attribute_code' => '1'],
true
],
+ [
+ Import::BEHAVIOR_APPEND,
+ ['is_required' => true, 'type' => 'decimal'],
+ ['product_type' => 'any', 'price' => ''],
+ true,
+ 'price'
+ ],
[
Import::BEHAVIOR_APPEND,
['is_required' => true, 'type' => 'boolean', 'options' => ['yes' => 0, 'no' => 1]],
diff --git a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php
index 7ea2507330d85..097557ec11705 100644
--- a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php
@@ -802,6 +802,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
$error = false;
$dataWithExtraVirtualRows = $this->_parseVariations($rowData);
$skus = [];
+ $rowData['price'] = isset($rowData['price']) && $rowData['price'] ? $rowData['price'] : '0.00';
if (!empty($dataWithExtraVirtualRows)) {
array_unshift($dataWithExtraVirtualRows, $rowData);
} else {
diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php
index 784366aa2a299..6deefd22e723c 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php
@@ -65,6 +65,9 @@ public function aroundValidate(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\DataObject $response
) {
+ if ($request->has('attributes')) {
+ $product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
+ }
$result = $proceed($product, $request, $response);
$variationProducts = (array)$request->getPost('variations-matrix');
if ($variationProducts) {
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js
index 99544c0e29bc2..1f04719da9954 100644
--- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js
+++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js
@@ -10,17 +10,26 @@ define([
'use strict';
return {
+ $initiallyDisabledAttributes: [],
$links: $('[data-ui-id=product-tabs-tab-link-advanced-pricing]'),
$tab: $('[data-tab-panel=advanced-pricing]'),
toggleDisabledAttribute: function (disabled) {
$('input,select', this.$tab).each(function (index, element) {
- $(element).attr('disabled', disabled);
+ if (!$.inArray(element, this.$initiallyDisabledAttributes)) {
+ $(element).attr('disabled', disabled);
+ }
});
},
init: function () {
$(document).on('changeTypeProduct', this._initType.bind(this));
+ this._setInitialState();
this._initType();
},
+ _setInitialState: function () {
+ if (this.$initiallyDisabledAttributes.length == 0) {
+ this.$initiallyDisabledAttributes = $('input:disabled,select:disabled', this.$tab).toArray();
+ }
+ },
_initType: function () {
var isConfigurable = productType.type.current === 'configurable';
diff --git a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
index 4e1087fb6aa9f..597f590db8562 100644
--- a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
+++ b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
@@ -6,7 +6,7 @@
namespace Magento\ImportExport\Model\Export\Adapter;
use Magento\Framework\Filesystem;
-use Magento\Framework\Filesystem\DirectoryList;
+use Magento\Framework\App\Filesystem\DirectoryList;
/**
* Abstract adapter model
@@ -45,7 +45,7 @@ abstract class AbstractAdapter
public function __construct(
\Magento\Framework\Filesystem $filesystem,
$destination = null,
- $destinationDirectoryCode = DirectoryList::SYS_TMP
+ $destinationDirectoryCode = DirectoryList::VAR_DIR
) {
$this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode);
if (!$destination) {
diff --git a/app/code/Magento/Msrp/view/base/web/js/msrp.js b/app/code/Magento/Msrp/view/base/web/js/msrp.js
index a63001b5bc842..fe5643d5b2baa 100644
--- a/app/code/Magento/Msrp/view/base/web/js/msrp.js
+++ b/app/code/Magento/Msrp/view/base/web/js/msrp.js
@@ -210,11 +210,6 @@ define([
this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice);
this.$popup.find(this.options.priceLabelId).html(this.options.realPrice);
this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open');
- this.$popup.find('button').on('click', function () {
- if (this.options.addToCartButton) {
- $(this.options.addToCartButton).click();
- }
- }.bind(this));
this._toggle(this.$popup);
if (!this.options.isSaleable) {
diff --git a/app/code/Magento/ProductVideo/etc/config.xml b/app/code/Magento/ProductVideo/etc/config.xml
index 127ba79e77d60..248336315db32 100644
--- a/app/code/Magento/ProductVideo/etc/config.xml
+++ b/app/code/Magento/ProductVideo/etc/config.xml
@@ -9,7 +9,7 @@
- 1
+ 0
0
0
diff --git a/app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php b/app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php
index ded4d146c12d2..339ba7dc43419 100644
--- a/app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php
+++ b/app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php
@@ -253,11 +253,11 @@ protected function extractNecessarySwatchData(array $swatchDataArray)
if ($result['type'] == Swatch::SWATCH_TYPE_VISUAL_IMAGE && !empty($swatchDataArray['value'])) {
$result['value'] = $this->swatchMediaHelper->getSwatchAttributeImage(
- 'swatch_image',
+ Swatch::SWATCH_IMAGE_NAME,
$swatchDataArray['value']
);
$result['thumb'] = $this->swatchMediaHelper->getSwatchAttributeImage(
- 'swatch_thumb',
+ Swatch::SWATCH_THUMBNAIL_NAME,
$swatchDataArray['value']
);
} else {
@@ -284,8 +284,8 @@ protected function getVariationMedia($attributeCode, $optionId)
$variationMediaArray = [];
if ($variationProduct) {
$variationMediaArray = [
- 'value' => $this->getSwatchProductImage($variationProduct, 'swatch_image'),
- 'thumb' => $this->getSwatchProductImage($variationProduct, 'swatch_thumb'),
+ 'value' => $this->getSwatchProductImage($variationProduct, Swatch::SWATCH_IMAGE_NAME),
+ 'thumb' => $this->getSwatchProductImage($variationProduct, Swatch::SWATCH_THUMBNAIL_NAME),
];
}
@@ -299,22 +299,28 @@ protected function getVariationMedia($attributeCode, $optionId)
*/
protected function getSwatchProductImage(Product $childProduct, $imageType)
{
- if (
- $childProduct->getData('swatch_image') !== null
- && $childProduct->getData('swatch_image') != self::EMPTY_IMAGE_VALUE
- ) {
- $swatchImageId = $imageType == 'swatch_image' ? 'swatch_image' : 'swatch_thumb';
- } elseif (
- $childProduct->getData('image') !== null
- && $childProduct->getData('image') != self::EMPTY_IMAGE_VALUE
- ) {
- $swatchImageId = $imageType == 'swatch_image' ? 'swatch_image_base' : 'swatch_thumb_base';
+ if ($this->isProductHasImage($childProduct, Swatch::SWATCH_IMAGE_NAME)) {
+ $swatchImageId = $imageType;
+ $imageAttributes = ['type' => Swatch::SWATCH_IMAGE_NAME];
+ } elseif ($this->isProductHasImage($childProduct, 'image')) {
+ $swatchImageId = $imageType == Swatch::SWATCH_IMAGE_NAME ? 'swatch_image_base' : 'swatch_thumb_base';
+ $imageAttributes = ['type' => 'image'];
}
if (isset($swatchImageId)) {
- return $this->_imageHelper->init($childProduct, $swatchImageId)->getUrl();
+ return $this->_imageHelper->init($childProduct, $swatchImageId, $imageAttributes)->getUrl();
}
}
+ /**
+ * @param Product $product
+ * @param string $imageType
+ * @return bool
+ */
+ protected function isProductHasImage(Product $product, $imageType)
+ {
+ return $product->getData($imageType) !== null && $product->getData($imageType) != self::EMPTY_IMAGE_VALUE;
+ }
+
/**
* @param array $attributeData
* @return array
diff --git a/app/code/Magento/Swatches/Model/Plugin/Product.php b/app/code/Magento/Swatches/Model/Plugin/Product.php
index b0ad0fd021322..8d731a4b7a5f3 100644
--- a/app/code/Magento/Swatches/Model/Plugin/Product.php
+++ b/app/code/Magento/Swatches/Model/Plugin/Product.php
@@ -10,11 +10,6 @@
*/
class Product
{
- /**
- * Name of swatch image role
- */
- const ROLE_SWATCH_IMAGE_NAME = 'swatch_image';
-
/**
* Unset swatch image role if product is not simple
*
@@ -28,7 +23,7 @@ public function afterGetMediaAttributes(\Magento\Catalog\Model\Product $product,
&& $product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
) {
if (is_array($imageRoles)) {
- unset($imageRoles[self::ROLE_SWATCH_IMAGE_NAME]);
+ unset($imageRoles[\Magento\Swatches\Model\Swatch::SWATCH_IMAGE_NAME]);
}
}
diff --git a/app/code/Magento/Swatches/Model/Swatch.php b/app/code/Magento/Swatches/Model/Swatch.php
index cfb4d34e398dc..8a928c7bb95b1 100644
--- a/app/code/Magento/Swatches/Model/Swatch.php
+++ b/app/code/Magento/Swatches/Model/Swatch.php
@@ -40,6 +40,16 @@ class Swatch extends \Magento\Framework\Model\AbstractModel
/** Constant for identifying empty swatch type */
const SWATCH_TYPE_EMPTY = 3;
+ /**
+ * Name of swatch image
+ */
+ const SWATCH_IMAGE_NAME = 'swatch_image';
+
+ /**
+ * Name of swatch thumbnail
+ */
+ const SWATCH_THUMBNAIL_NAME = 'swatch_thumb';
+
/**
* Initialize resource model
*
diff --git a/app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php b/app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php
index e95c5dd2b32e7..2b3500f057f31 100644
--- a/app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php
+++ b/app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php
@@ -176,8 +176,8 @@ public function testGetJsonSwatchConfigNotVisualImageType()
$this->imageHelper->expects($this->exactly(2))->method('init')
->willReturnMap([
- [$this->product, 'swatch_image', [], $this->imageHelper],
- [$this->product, 'swatch_thumb', [], $this->imageHelper],
+ [$this->product, 'swatch_image', ['type' => 'swatch_image'], $this->imageHelper],
+ [$this->product, 'swatch_thumb', ['type' => 'swatch_image'], $this->imageHelper],
]);
$this->jsonEncoder->expects($this->once())->method('encode');
@@ -222,8 +222,8 @@ public function testGetJsonSwatchConfigVisualImageType()
$this->imageHelper->expects($this->exactly(2))->method('init')
->willReturnMap([
- [$this->product, 'swatch_image_base', [], $this->imageHelper],
- [$this->product, 'swatch_thumb_base', [], $this->imageHelper],
+ [$this->product, 'swatch_image_base', ['type' => 'image'], $this->imageHelper],
+ [$this->product, 'swatch_thumb_base', ['type' => 'image'], $this->imageHelper],
]);
$this->jsonEncoder->expects($this->once())->method('encode');
diff --git a/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js b/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js
index 0baa01cffda9c..6a0070d570cc8 100644
--- a/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js
+++ b/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js
@@ -2,24 +2,15 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-Number.prototype.formatMoney = function (c, d, t) { //this function helps format price
- var n = this,
- c = isNaN(c = Math.abs(c)) ? 2 : c,
- d = d == undefined ? "." : d,
- t = t == undefined ? "," : t,
- s = n < 0 ? "-" : "",
- i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
- j = (j = i.length) > 3 ? j % 3 : 0;
- return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
-};
-
-Array.prototype.intersection = function (a) {
- return this.filter(function (i) {
- return a.indexOf(i) >= 0;
- });
-};
-define(["jquery", "jquery/ui"], function ($) {
+define(['jquery', 'underscore', 'jquery/ui'], function ($, _) {
+ 'use strict';
+
+ /**
+ * Parse params
+ * @param {String} query
+ * @returns {{}}
+ */
$.parseParams = function (query) {
var re = /([^&=]+)=?([^&]*)/g,
decodeRE = /\+/g, // Regex for replacing addition symbol with a space
@@ -176,7 +167,7 @@ define(["jquery", "jquery/ui"], function ($) {
jsonConfig: {}, // option's json config
jsonSwatchConfig: {}, // swatch's json config
selectorProduct: '.product-info-main', // selector of parental block of prices and swatches (need to know where to seek for price block)
- selectorProductPrice: '.price-final-price .price', // selector of price wrapper (need to know where set price)
+ selectorProductPrice: '[data-role=priceBox]', // selector of price wrapper (need to know where set price)
numberToShow: false, // number of controls to show (false or zero = show all)
onlySwatches: false, // show only swatch controls
enableControlLabel: true, // enable label for control
@@ -476,7 +467,13 @@ define(["jquery", "jquery/ui"], function ($) {
}
$widget._Rebuild();
- $widget._UpdatePrice();
+
+ if ($widget.element.parents($widget.options.selectorProduct)
+ .find(this.options.selectorProductPrice).is(':data(mage-priceBox)')
+ ) {
+ $widget._UpdatePrice();
+ }
+
$widget._LoadProductMedia();
},
@@ -564,7 +561,7 @@ define(["jquery", "jquery/ui"], function ($) {
return;
}
- if (products.intersection($widget.optionsMap[id][option].products).length <= 0) {
+ if (_.intersection(products, $widget.optionsMap[id][option].products).length <= 0) {
$this.attr('disabled', true).addClass('disabled');
}
});
@@ -597,7 +594,7 @@ define(["jquery", "jquery/ui"], function ($) {
if (products.length == 0) {
products = $widget.optionsMap[id][option].products;
} else {
- products = products.intersection($widget.optionsMap[id][option].products);
+ products = _.intersection(products, $widget.optionsMap[id][option].products);
}
});
@@ -612,21 +609,48 @@ define(["jquery", "jquery/ui"], function ($) {
_UpdatePrice: function () {
var $widget = this,
$product = $widget.element.parents($widget.options.selectorProduct),
- price = $product.find('[data-price-amount]').data('price-amount');
+ $productPrice = $product.find(this.options.selectorProductPrice),
+ options = _.object(_.keys($widget.optionsMap), {}),
+ result;
$widget.element.find('.' + $widget.options.classes.attributeClass + '[option-selected]').each(function () {
- var id = $(this).attr('attribute-id');
- var option = $(this).attr('option-selected');
+ var attributeId = $(this).attr('attribute-id'),
+ selectedOptionId = $(this).attr('option-selected');
+
+ options[attributeId] = selectedOptionId;
+ });
+
+ result = $widget.options.jsonConfig.optionPrices[_.findKey($widget.options.jsonConfig.index, options)];
- price = $widget.optionsMap[id][option].price;
+ $productPrice.trigger(
+ 'updatePrice',
+ {
+ 'prices': $widget._getPrices(result, $productPrice.priceBox('option').prices)
+ }
+ );
+
+ },
+
+ /**
+ * Get prices
+ * @param {Object} newPrices
+ * @returns {Object}
+ * @private
+ */
+ _getPrices: function (newPrices, displayPrices) {
+ var $widget = this;
+
+ if (_.isEmpty(newPrices)) {
+ newPrices = $widget.options.jsonConfig.prices;
+ }
+
+ _.each(displayPrices, function (price, code) {
+ if (newPrices[code]) {
+ displayPrices[code].amount = newPrices[code].amount - displayPrices[code].amount;
+ }
});
- $product
- .find($widget.options.selectorProductPrice)
- .text($widget.options.jsonConfig.template.replace(
- '<%- data.price %>',
- price.formatMoney(2)
- ));
+ return displayPrices;
},
/**
diff --git a/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php b/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php
index 9341880ef175a..0f4262953b9ec 100644
--- a/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php
+++ b/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php
@@ -174,31 +174,9 @@ public function getFilenameDataProvider()
public function testGetViewConfig()
{
$this->_emulateFixtureTheme();
- /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
- $theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
- 'Magento\Framework\View\DesignInterface'
- )->getDesignTheme();
- $customConfigFile = $theme->getCustomization()->getCustomViewConfigPath();
- /** @var $filesystem \Magento\Framework\Filesystem */
- $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\Framework\Filesystem');
- $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
- $relativePath = $directory->getRelativePath($customConfigFile);
- try {
- $directory->writeFile(
- $relativePath,
- '
- var value'
- );
-
- $config = $this->_viewConfig->getViewConfig();
- $this->assertInstanceOf('Magento\Framework\Config\View', $config);
- $this->assertEquals('var value', $config->getVarValue('Namespace_Module', 'var'));
- } catch (\Exception $e) {
- $directory->delete($relativePath);
- throw $e;
- }
- $directory->delete($relativePath);
+ $config = $this->_viewConfig->getViewConfig();
+ $this->assertInstanceOf('Magento\Framework\Config\View', $config);
+ $this->assertEquals(['var1' => 'value1', 'var2' => 'value2'], $config->getVars('Namespace_Module'));
}
/**
diff --git a/lib/internal/Magento/Framework/App/Router/ActionList.php b/lib/internal/Magento/Framework/App/Router/ActionList.php
index dd561b99d7468..62354004853cd 100644
--- a/lib/internal/Magento/Framework/App/Router/ActionList.php
+++ b/lib/internal/Magento/Framework/App/Router/ActionList.php
@@ -80,9 +80,12 @@ public function get($module, $area, $namespace, $action)
if (in_array(strtolower($action), $this->reservedWords)) {
$action .= 'action';
}
- $fullPath = strtolower(
- str_replace('_', '\\', $module) . '\\controller' . $area
- . '\\' . str_replace('_', '\\', $namespace) . '\\' . $action
+ $fullPath = str_replace(
+ '_',
+ '\\',
+ strtolower(
+ $module . '\\controller' . $area . '\\' . $namespace . '\\' . $action
+ )
);
if (isset($this->actions[$fullPath])) {
return is_subclass_of($this->actions[$fullPath], $this->actionInterface) ? $this->actions[$fullPath] : null;
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php
index 3502e17fbe674..a286d0fc577b5 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php
@@ -142,14 +142,6 @@ public function getDataProvider()
['magento\module\controller\area\namespace\catchaction' => $mockClassName],
$actionClass
],
- [
- 'Magento_Module',
- 'Area',
- 'Namespace_A',
- 'Index_edit',
- ['magento\module\controller\area\namespace\a\index_edit' => $mockClassName],
- $actionClass
- ],
[
'Magento_Module',
'Area',
diff --git a/lib/internal/Magento/Framework/Config/FileResolver.php b/lib/internal/Magento/Framework/Config/FileResolver.php
index 0af746da34d3d..c758370ccb1d4 100644
--- a/lib/internal/Magento/Framework/Config/FileResolver.php
+++ b/lib/internal/Magento/Framework/Config/FileResolver.php
@@ -11,7 +11,7 @@
use Magento\Framework\Filesystem;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Symfony\Component\Config\Definition\Exception\Exception;
+use Magento\Framework\Component\ComponentRegistrar;
class FileResolver implements \Magento\Framework\Config\FileResolverInterface
{
@@ -43,25 +43,30 @@ class FileResolver implements \Magento\Framework\Config\FileResolverInterface
protected $area;
/**
- * Root directory
- *
- * @var ReadInterface
+ * @var Filesystem\Directory\ReadInterface
*/
protected $rootDirectory;
+ /**
+ * @var \Magento\Framework\Component\ComponentRegistrar
+ */
+ protected $componentRegistrar;
+
/**
* @param Reader $moduleReader
* @param FileIteratorFactory $iteratorFactory
* @param DesignInterface $designInterface
* @param DirectoryList $directoryList
* @param Filesystem $filesystem
+ * @param ComponentRegistrar $componentRegistrar
*/
public function __construct(
Reader $moduleReader,
FileIteratorFactory $iteratorFactory,
DesignInterface $designInterface,
DirectoryList $directoryList,
- Filesystem $filesystem
+ Filesystem $filesystem,
+ ComponentRegistrar $componentRegistrar
) {
$this->directoryList = $directoryList;
$this->iteratorFactory = $iteratorFactory;
@@ -70,6 +75,7 @@ public function __construct(
$this->themePath = $designInterface->getThemePath($this->currentTheme);
$this->area = $designInterface->getArea();
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
+ $this->componentRegistrar = $componentRegistrar;
}
/**
@@ -80,29 +86,32 @@ public function get($filename, $scope)
switch ($scope) {
case 'global':
$iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
-
$themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
if ($themeConfigFile
&& $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
) {
- $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
- $this->rootDirectory->getRelativePath($themeConfigFile)
- );
- }
-
- $designPath =
- $this->directoryList->getPath(DirectoryList::APP)
- . '/design/'
- . $this->area
- . '/'
- . $this->themePath
- . '/etc/view.xml';
- if (file_exists($designPath)) {
- try {
- $designDom = new \DOMDocument;
- $designDom->load($designPath);
- $iterator[$designPath] = $designDom->saveXML();
- } catch (Exception $e) {
+ $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] =
+ $this->rootDirectory->readFile(
+ $this->rootDirectory->getRelativePath(
+ $themeConfigFile
+ )
+ );
+ } else {
+ $designPath =
+ $this->componentRegistrar->getPath(
+ ComponentRegistrar::THEME,
+ $this->area . '/' . $this->themePath
+ ) . '/etc/view.xml';
+ if (file_exists($designPath)) {
+ try {
+ $designDom = new \DOMDocument;
+ $designDom->load($designPath);
+ $iterator[$designPath] = $designDom->saveXML();
+ } catch (\Exception $e) {
+ throw new \Magento\Framework\Exception\LocalizedException(
+ new \Magento\Framework\Phrase('Could not read config file')
+ );
+ }
}
}
break;
diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php
index ac907e5e6dad6..09bf95ca4d4c3 100644
--- a/lib/internal/Magento/Framework/Config/View.php
+++ b/lib/internal/Magento/Framework/Config/View.php
@@ -18,6 +18,13 @@ class View extends \Magento\Framework\Config\Reader\Filesystem
*/
protected $xpath;
+ /**
+ * View config data
+ *
+ * @var array
+ */
+ protected $data;
+
/**
* @param FileResolverInterface $fileResolver
* @param ConverterInterface $converter
@@ -52,7 +59,6 @@ public function __construct(
$domDocumentClass,
$defaultScope
);
- $this->data = $this->read();
}
/**
@@ -65,6 +71,7 @@ public function __construct(
*/
public function getVars($module)
{
+ $this->initData();
return isset($this->data['vars'][$module]) ? $this->data['vars'][$module] : [];
}
@@ -77,6 +84,7 @@ public function getVars($module)
*/
public function getVarValue($module, $var)
{
+ $this->initData();
if (!isset($this->data['vars'][$module])) {
return false;
}
@@ -102,6 +110,7 @@ public function getVarValue($module, $var)
*/
public function getMediaEntities($module, $mediaType)
{
+ $this->initData();
return isset($this->data['media'][$module][$mediaType]) ? $this->data['media'][$module][$mediaType] : [];
}
@@ -115,6 +124,7 @@ public function getMediaEntities($module, $mediaType)
*/
public function getMediaAttributes($module, $mediaType, $mediaId)
{
+ $this->initData();
return isset($this->data['media'][$module][$mediaType][$mediaId])
? $this->data['media'][$module][$mediaType][$mediaId]
: [];
@@ -185,6 +195,19 @@ public function getExcludedDir()
*/
protected function getItems()
{
+ $this->initData();
return isset($this->data['exclude']) ? $this->data['exclude'] : [];
}
+
+ /**
+ * Initialize data array
+ *
+ * @return void
+ */
+ protected function initData()
+ {
+ if ($this->data === null) {
+ $this->data = $this->read();
+ }
+ }
}