Skip to content

Commit 0d08a72

Browse files
author
Miniailo, Igor(iminiailo)
committed
Merge pull request #110 from magento-nord/MAGETWO-44145
[EPAM][NORD+GOINC+TROLL+DRAGONS] Bugfixes
2 parents 16dc76d + dddd5b1 commit 0d08a72

File tree

24 files changed

+206
-142
lines changed

24 files changed

+206
-142
lines changed

app/code/Magento/Bundle/view/adminhtml/templates/catalog/product/edit/tab/attributes/extend.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ $isElementReadonly = $block->getElement()
6161
&& !$block->getProduct()->isObjectNew())) { ?>
6262
$('<?= /* @escapeNotVerified */ $switchAttributeCode?>').observe('change', <?= /* @escapeNotVerified */ $switchAttributeCode?>_change);
6363
<?php } ?>
64-
<?= /* @escapeNotVerified */ $switchAttributeCode?>_change();
64+
Event.observe(window, 'load', function(){
65+
<?= /* @escapeNotVerified */ $switchAttributeCode?>_change();
66+
});
6567
});
6668
</script>
6769
<?php } ?>

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ public function saveData()
384384
public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
385385
{
386386
$rowData = array_merge($rowData, $this->transformBundleCustomAttributes($rowData));
387+
if (isset($rowData['bundle_price_type']) && $rowData['bundle_price_type'] == 'dynamic') {
388+
$rowData['price'] = isset($rowData['price']) && $rowData['price'] ? $rowData['price'] : '0.00';
389+
}
387390
return parent::isRowValid($rowData, $rowNum, $isNewProduct);
388391
}
389392

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ public function testIsRowValid()
377377
{
378378
$this->entityModel->expects($this->any())->method('getRowScope')->will($this->returnValue(-1));
379379
$rowData = [
380-
'price_type' => 'fixed',
381-
'price_view' => 'bundle_price_view'
380+
'bundle_price_type' => 'dynamic',
381+
'bundle_price_view' => 'bundle_price_view'
382382
];
383383
$this->assertEquals($this->bundle->isRowValid($rowData, 0), true);
384384
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ public function getAfterElementHtml()
7171
$addJsObserver = false;
7272
if ($attribute = $this->getEntityAttribute()) {
7373
$store = $this->getStore($attribute);
74-
$html .= '<strong>' . $this->_localeCurrency->getCurrency(
75-
$store->getBaseCurrencyCode()
76-
)->getSymbol() . '</strong>';
74+
if ($this->getType() !== 'hidden') {
75+
$html .= '<strong>'
76+
. $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode())->getSymbol()
77+
. '</strong>';
78+
}
7779
if ($this->_taxData->priceIncludesTax($store)) {
7880
if ($attribute->getAttributeCode() !== 'cost') {
7981
$addJsObserver = true;

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function init($product, $imageId, $attributes = [])
176176
$this->_reset();
177177

178178
$this->attributes = array_merge(
179-
$attributes,
180-
$this->getConfigView()->getMediaAttributes('Magento_Catalog', self::MEDIA_TYPE_CONFIG_NODE, $imageId)
179+
$this->getConfigView()->getMediaAttributes('Magento_Catalog', self::MEDIA_TYPE_CONFIG_NODE, $imageId),
180+
$attributes
181181
);
182182

183183
$this->setProduct($product);

app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,9 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
418418
{
419419
$error = false;
420420
$rowScope = $this->_entityModel->getRowScope($rowData);
421-
if ((\Magento\CatalogImportExport\Model\Import\Product::SCOPE_NULL != $rowScope) &&
422-
!empty($rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_SKU])) {
423-
424-
421+
if (\Magento\CatalogImportExport\Model\Import\Product::SCOPE_NULL != $rowScope
422+
&& !empty($rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_SKU])
423+
) {
425424
foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
426425
// check value for non-empty in the case of required attribute?
427426
if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
@@ -437,9 +436,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
437436
))
438437
) {
439438
$this->_entityModel->addRowError(
440-
// @codingStandardsIgnoreStart
441-
\Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
442-
// @codingStandardsIgnoreEnd
439+
RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
443440
$rowNum,
444441
$attrCode
445442
);

app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function isRequiredAttributeValid($attrCode, array $attributeParams, arra
104104
$doCheck = false;
105105
if ($attrCode == Product::COL_SKU) {
106106
$doCheck = true;
107+
} elseif ($attrCode == 'price') {
108+
$doCheck = false;
107109
} elseif ($attributeParams['is_required'] && $this->getRowScope($rowData) == Product::SCOPE_DEFAULT
108110
&& $this->context->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE
109111
) {
@@ -124,7 +126,9 @@ public function isRequiredAttributeValid($attrCode, array $attributeParams, arra
124126
public function isAttributeValid($attrCode, array $attrParams, array $rowData)
125127
{
126128
$this->_rowData = $rowData;
127-
if (!empty($attrParams['apply_to']) && !in_array($rowData['product_type'], $attrParams['apply_to'])) {
129+
if (isset($rowData['product_type']) && !empty($attrParams['apply_to'])
130+
&& !in_array($rowData['product_type'], $attrParams['apply_to'])
131+
) {
128132
return true;
129133
}
130134

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function testAttributeValidation($behavior, $attrParams, $rowData, $isVal
9898

9999
/**
100100
* @return array
101+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101102
*/
102103
public function attributeValidationProvider()
103104
{
@@ -147,6 +148,13 @@ public function attributeValidationProvider()
147148
['product_type' => 'any', 'attribute_code' => '1'],
148149
true
149150
],
151+
[
152+
Import::BEHAVIOR_APPEND,
153+
['is_required' => true, 'type' => 'decimal'],
154+
['product_type' => 'any', 'price' => ''],
155+
true,
156+
'price'
157+
],
150158
[
151159
Import::BEHAVIOR_APPEND,
152160
['is_required' => true, 'type' => 'boolean', 'options' => ['yes' => 0, 'no' => 1]],

app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
802802
$error = false;
803803
$dataWithExtraVirtualRows = $this->_parseVariations($rowData);
804804
$skus = [];
805+
$rowData['price'] = isset($rowData['price']) && $rowData['price'] ? $rowData['price'] : '0.00';
805806
if (!empty($dataWithExtraVirtualRows)) {
806807
array_unshift($dataWithExtraVirtualRows, $rowData);
807808
} else {

app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public function aroundValidate(
6565
\Magento\Framework\App\RequestInterface $request,
6666
\Magento\Framework\DataObject $response
6767
) {
68+
if ($request->has('attributes')) {
69+
$product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
70+
}
6871
$result = $proceed($product, $request, $response);
6972
$variationProducts = (array)$request->getPost('variations-matrix');
7073
if ($variationProducts) {

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,26 @@ define([
1010
'use strict';
1111

1212
return {
13+
$initiallyDisabledAttributes: [],
1314
$links: $('[data-ui-id=product-tabs-tab-link-advanced-pricing]'),
1415
$tab: $('[data-tab-panel=advanced-pricing]'),
1516
toggleDisabledAttribute: function (disabled) {
1617
$('input,select', this.$tab).each(function (index, element) {
17-
$(element).attr('disabled', disabled);
18+
if (!$.inArray(element, this.$initiallyDisabledAttributes)) {
19+
$(element).attr('disabled', disabled);
20+
}
1821
});
1922
},
2023
init: function () {
2124
$(document).on('changeTypeProduct', this._initType.bind(this));
25+
this._setInitialState();
2226
this._initType();
2327
},
28+
_setInitialState: function () {
29+
if (this.$initiallyDisabledAttributes.length == 0) {
30+
this.$initiallyDisabledAttributes = $('input:disabled,select:disabled', this.$tab).toArray();
31+
}
32+
},
2433
_initType: function () {
2534
var isConfigurable = productType.type.current === 'configurable';
2635

app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\ImportExport\Model\Export\Adapter;
77

88
use Magento\Framework\Filesystem;
9-
use Magento\Framework\Filesystem\DirectoryList;
9+
use Magento\Framework\App\Filesystem\DirectoryList;
1010

1111
/**
1212
* Abstract adapter model
@@ -45,7 +45,7 @@ abstract class AbstractAdapter
4545
public function __construct(
4646
\Magento\Framework\Filesystem $filesystem,
4747
$destination = null,
48-
$destinationDirectoryCode = DirectoryList::SYS_TMP
48+
$destinationDirectoryCode = DirectoryList::VAR_DIR
4949
) {
5050
$this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode);
5151
if (!$destination) {

app/code/Magento/Msrp/view/base/web/js/msrp.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ define([
210210
this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice);
211211
this.$popup.find(this.options.priceLabelId).html(this.options.realPrice);
212212
this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open');
213-
this.$popup.find('button').on('click', function () {
214-
if (this.options.addToCartButton) {
215-
$(this.options.addToCartButton).click();
216-
}
217-
}.bind(this));
218213
this._toggle(this.$popup);
219214

220215
if (!this.options.isSaleable) {

app/code/Magento/ProductVideo/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<default>
1010
<catalog>
1111
<product_video>
12-
<play_if_base>1</play_if_base>
12+
<play_if_base>0</play_if_base>
1313
<show_related>0</show_related>
1414
<video_auto_restart>0</video_auto_restart>
1515
</product_video>

app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ protected function extractNecessarySwatchData(array $swatchDataArray)
253253

254254
if ($result['type'] == Swatch::SWATCH_TYPE_VISUAL_IMAGE && !empty($swatchDataArray['value'])) {
255255
$result['value'] = $this->swatchMediaHelper->getSwatchAttributeImage(
256-
'swatch_image',
256+
Swatch::SWATCH_IMAGE_NAME,
257257
$swatchDataArray['value']
258258
);
259259
$result['thumb'] = $this->swatchMediaHelper->getSwatchAttributeImage(
260-
'swatch_thumb',
260+
Swatch::SWATCH_THUMBNAIL_NAME,
261261
$swatchDataArray['value']
262262
);
263263
} else {
@@ -284,8 +284,8 @@ protected function getVariationMedia($attributeCode, $optionId)
284284
$variationMediaArray = [];
285285
if ($variationProduct) {
286286
$variationMediaArray = [
287-
'value' => $this->getSwatchProductImage($variationProduct, 'swatch_image'),
288-
'thumb' => $this->getSwatchProductImage($variationProduct, 'swatch_thumb'),
287+
'value' => $this->getSwatchProductImage($variationProduct, Swatch::SWATCH_IMAGE_NAME),
288+
'thumb' => $this->getSwatchProductImage($variationProduct, Swatch::SWATCH_THUMBNAIL_NAME),
289289
];
290290
}
291291

@@ -299,22 +299,28 @@ protected function getVariationMedia($attributeCode, $optionId)
299299
*/
300300
protected function getSwatchProductImage(Product $childProduct, $imageType)
301301
{
302-
if (
303-
$childProduct->getData('swatch_image') !== null
304-
&& $childProduct->getData('swatch_image') != self::EMPTY_IMAGE_VALUE
305-
) {
306-
$swatchImageId = $imageType == 'swatch_image' ? 'swatch_image' : 'swatch_thumb';
307-
} elseif (
308-
$childProduct->getData('image') !== null
309-
&& $childProduct->getData('image') != self::EMPTY_IMAGE_VALUE
310-
) {
311-
$swatchImageId = $imageType == 'swatch_image' ? 'swatch_image_base' : 'swatch_thumb_base';
302+
if ($this->isProductHasImage($childProduct, Swatch::SWATCH_IMAGE_NAME)) {
303+
$swatchImageId = $imageType;
304+
$imageAttributes = ['type' => Swatch::SWATCH_IMAGE_NAME];
305+
} elseif ($this->isProductHasImage($childProduct, 'image')) {
306+
$swatchImageId = $imageType == Swatch::SWATCH_IMAGE_NAME ? 'swatch_image_base' : 'swatch_thumb_base';
307+
$imageAttributes = ['type' => 'image'];
312308
}
313309
if (isset($swatchImageId)) {
314-
return $this->_imageHelper->init($childProduct, $swatchImageId)->getUrl();
310+
return $this->_imageHelper->init($childProduct, $swatchImageId, $imageAttributes)->getUrl();
315311
}
316312
}
317313

314+
/**
315+
* @param Product $product
316+
* @param string $imageType
317+
* @return bool
318+
*/
319+
protected function isProductHasImage(Product $product, $imageType)
320+
{
321+
return $product->getData($imageType) !== null && $product->getData($imageType) != self::EMPTY_IMAGE_VALUE;
322+
}
323+
318324
/**
319325
* @param array $attributeData
320326
* @return array

app/code/Magento/Swatches/Model/Plugin/Product.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
*/
1111
class Product
1212
{
13-
/**
14-
* Name of swatch image role
15-
*/
16-
const ROLE_SWATCH_IMAGE_NAME = 'swatch_image';
17-
1813
/**
1914
* Unset swatch image role if product is not simple
2015
*
@@ -28,7 +23,7 @@ public function afterGetMediaAttributes(\Magento\Catalog\Model\Product $product,
2823
&& $product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
2924
) {
3025
if (is_array($imageRoles)) {
31-
unset($imageRoles[self::ROLE_SWATCH_IMAGE_NAME]);
26+
unset($imageRoles[\Magento\Swatches\Model\Swatch::SWATCH_IMAGE_NAME]);
3227
}
3328
}
3429

app/code/Magento/Swatches/Model/Swatch.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ class Swatch extends \Magento\Framework\Model\AbstractModel
4040
/** Constant for identifying empty swatch type */
4141
const SWATCH_TYPE_EMPTY = 3;
4242

43+
/**
44+
* Name of swatch image
45+
*/
46+
const SWATCH_IMAGE_NAME = 'swatch_image';
47+
48+
/**
49+
* Name of swatch thumbnail
50+
*/
51+
const SWATCH_THUMBNAIL_NAME = 'swatch_thumb';
52+
4353
/**
4454
* Initialize resource model
4555
*

app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function testGetJsonSwatchConfigNotVisualImageType()
176176

177177
$this->imageHelper->expects($this->exactly(2))->method('init')
178178
->willReturnMap([
179-
[$this->product, 'swatch_image', [], $this->imageHelper],
180-
[$this->product, 'swatch_thumb', [], $this->imageHelper],
179+
[$this->product, 'swatch_image', ['type' => 'swatch_image'], $this->imageHelper],
180+
[$this->product, 'swatch_thumb', ['type' => 'swatch_image'], $this->imageHelper],
181181
]);
182182

183183
$this->jsonEncoder->expects($this->once())->method('encode');
@@ -222,8 +222,8 @@ public function testGetJsonSwatchConfigVisualImageType()
222222

223223
$this->imageHelper->expects($this->exactly(2))->method('init')
224224
->willReturnMap([
225-
[$this->product, 'swatch_image_base', [], $this->imageHelper],
226-
[$this->product, 'swatch_thumb_base', [], $this->imageHelper],
225+
[$this->product, 'swatch_image_base', ['type' => 'image'], $this->imageHelper],
226+
[$this->product, 'swatch_thumb_base', ['type' => 'image'], $this->imageHelper],
227227
]);
228228

229229
$this->jsonEncoder->expects($this->once())->method('encode');

0 commit comments

Comments
 (0)