Skip to content

Commit 7dbdf6c

Browse files
author
Dale Sikkema
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents c8ab66c + 0d08a72 commit 7dbdf6c

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) {

0 commit comments

Comments
 (0)