Skip to content

Commit

Permalink
Merge pull request #1339 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests

 - MAGETWO-70817: remove redundant else and use strict check #10271
 - MAGETWO-70787: update phpserver to support versioned static urls #10250
 - MAGETWO-70764: Fix overwrite default value image/file with NULL #10253
 - MAGETWO-70761: Show values that are duplicate in attribute error msg #10213
 - MAGETWO-70758: Fix for #4530 $product->getRatingSummary() always returns null […] #10248
 - MAGETWO-70706: simplify product lists #2 #9019
 - MAGETWO-70669: Fix fatal errors with deleteOptionsAndSelections #7711
 - MAGETWO-70464: Fix shipping address can use for billing #10130
 - MAGETWO-69913: magento/magento2 #9196 - Products ordered report doesn't show simple (child) products of configurable products #9908
  • Loading branch information
ishakhsuvarov committed Jul 18, 2017
2 parents 2e8d837 + 4b179ac commit 0a8e77a
Show file tree
Hide file tree
Showing 27 changed files with 742 additions and 711 deletions.
Expand Up @@ -648,8 +648,13 @@ protected function _initAttributes()
*/
protected function deleteOptionsAndSelections($productIds)
{
if (empty($productIds)) {
return $this;
}

$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
$valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
['bov' => $optionValueTable],
['value_id']
Expand All @@ -662,17 +667,16 @@ protected function deleteOptionsAndSelections($productIds)
$productIds
));
$this->connection->delete(
$optionTable,
$optionValueTable,
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
);
$productIdsInWhere = $this->connection->quoteInto('parent_id IN (?)', $productIds);
$this->connection->delete(
$optionTable,
$this->connection->quoteInto('parent_id IN (?)', $productIdsInWhere)
$this->connection->quoteInto('parent_id IN (?)', $productIds)
);
$this->connection->delete(
$optionTable,
$this->connection->quoteInto('parent_product_id IN (?)', $productIdsInWhere)
$selectionTable,
$this->connection->quoteInto('parent_product_id IN (?)', $productIds)
);
return $this;
}
Expand Down
Expand Up @@ -128,7 +128,7 @@ private function isUniqueAdminValues(array $optionsValues, array $deletedOptions
}
}
$uniqueValues = array_unique($adminValues);
return ($uniqueValues === $adminValues);
return array_diff_assoc($adminValues, $uniqueValues);
}

/**
Expand Down Expand Up @@ -157,10 +157,16 @@ private function checkUniqueOption(DataObject $response, array $options = null)
if (is_array($options)
&& !empty($options['value'])
&& !empty($options['delete'])
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
) {
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
$response->setError(true);
$duplicates = $this->isUniqueAdminValues($options['value'], $options['delete']);
if ($duplicates) {
$this->setMessageToResponse(
$response,
[__('The value of Admin must be unique. (%1)', implode(', ', $duplicates))]
);

$response->setError(true);
}
}
return $this;
}
Expand Down
Expand Up @@ -100,16 +100,16 @@ public function convertFrom(ProductAttributeMediaGalleryEntryInterface $entry)
protected function convertFromMediaGalleryEntryContentInterface(
ImageContentInterface $content = null
) {
if ($content == null) {
if ($content === null) {
return null;
} else {
return [
'data' => [
ImageContentInterface::BASE64_ENCODED_DATA => $content->getBase64EncodedData(),
ImageContentInterface::TYPE => $content->getType(),
ImageContentInterface::NAME => $content->getName(),
],
];
}

return [
'data' => [
ImageContentInterface::BASE64_ENCODED_DATA => $content->getBase64EncodedData(),
ImageContentInterface::TYPE => $content->getType(),
ImageContentInterface::NAME => $content->getName(),
],
];
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/i18n/en_US.csv
Expand Up @@ -717,3 +717,4 @@ none,none
Overview,Overview
Details,Details
"The value of Admin must be unique.", "The value of Admin must be unique."
"The value of Admin must be unique. (%1)", "The value of Admin must be unique. (%1)"
Expand Up @@ -10,11 +10,17 @@ define([
'use strict';

return function (config) {
var _config = jQuery.extend({
element: null,
message: '',
uniqueClass: 'required-unique'
}, config);
var msg = '',
_config = jQuery.extend({
element: null,
message: '',
uniqueClass: 'required-unique'
}, config),

/** @inheritdoc */
messager = function () {
return msg;
};

if (typeof _config.element === 'string') {
jQuery.validator.addMethod(
Expand All @@ -25,21 +31,27 @@ define([
.closest('table')
.find('.' + _config.uniqueClass + ':visible'),
valuesHash = {},
isValid = true;
isValid = true,
duplicates = [];

inputs.each(function (el) {
var inputValue = inputs[el].value;

if (typeof valuesHash[inputValue] !== 'undefined') {
isValid = false;
duplicates.push(inputValue);
}
valuesHash[inputValue] = el;
});

if (!isValid) {
msg = _config.message + ' (' + duplicates.join(', ') + ')';
}

return isValid;
},

_config.message
messager
);
}
};
Expand Down
Expand Up @@ -42,11 +42,10 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
$pos = $block->getPositioned();
?>
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?> products-<?= /* @escapeNotVerified */ $viewMode ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<li class="item product product-item">
<div class="product-item-info" data-container="product-grid">
<?php
$productImage = $block->getImage($_product, $image);
Expand Down Expand Up @@ -112,7 +111,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
</div>
</div>
</div>
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
</li>
<?php endforeach; ?>
</ol>
</div>
Expand Down
Expand Up @@ -174,7 +174,6 @@ switch ($type = $block->getType()) {
<?php endif; ?>
<div class="products wrapper grid products-grid products-<?= /* @escapeNotVerified */ $type ?>">
<ol class="products list items product-items">
<?php $iterator = 1; ?>
<?php foreach ($items as $_item): ?>
<?php $available = ''; ?>
<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
Expand All @@ -183,9 +182,9 @@ switch ($type = $block->getType()) {
<?php endif; ?>
<?php endif; ?>
<?php if ($type == 'related' || $type == 'upsell'): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item" style="display: none;">' : '</li><li class="item product product-item" style="display: none;">' ?>
<li class="item product product-item" style="display: none;">
<?php else: ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<li class="item product product-item">
<?php endif; ?>
<div class="product-item-info <?= /* @escapeNotVerified */ $available ?>">
<?= /* @escapeNotVerified */ '<!-- ' . $image . '-->' ?>
Expand Down Expand Up @@ -252,7 +251,7 @@ switch ($type = $block->getType()) {
<?php endif; ?>
</div>
</div>
<?= ($iterator == count($items)+1) ? '</li>' : '' ?>
</li>
<?php endforeach ?>
</ol>
</div>
Expand Down
Expand Up @@ -38,61 +38,60 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
}
?>
<div class="products wrapper <?= /* @escapeNotVerified */ $viewMode ?>">
<?php $iterator = 1; ?>
<ol class="products list items">
<?php foreach ($_productCollection as $_product): ?>
<?= /* @escapeNotVerified */ ($iterator++ == 1) ? '<li class="item product">' : '</li><li class="item product">' ?>
<div class="product">
<?php // Product Image ?>
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
<?= $block->getImage($_product, $image)->toHtml() ?>
</a>
<div class="product details">
<?php
<li class="item product">
<div class="product">
<?php // Product Image ?>
<a href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>" class="product photo">
<?= $block->getImage($_product, $image)->toHtml() ?>
</a>
<div class="product details">
<?php

$info = [];
$info['name'] = '<strong class="product name">'
. ' <a href="' . $_product->getProductUrl() . '" title="'
. $block->stripTags($_product->getName(), null, true) . '">'
. $_helper->productAttribute($_product, $_product->getName(), 'name')
. '</a></strong>';
$info['price'] = $block->getProductPrice($_product);
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);
$info = [];
$info['name'] = '<strong class="product name">'
. ' <a href="' . $_product->getProductUrl() . '" title="'
. $block->stripTags($_product->getName(), null, true) . '">'
. $_helper->productAttribute($_product, $_product->getName(), 'name')
. '</a></strong>';
$info['price'] = $block->getProductPrice($_product);
$info['review'] = $block->getReviewsSummaryHtml($_product, $templateType);

if ($_product->isSaleable()) {
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
. '<span>' . __('Add to Cart') . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
}
if ($_product->isSaleable()) {
$info['button'] = '<button type="button" title="' . __('Add to Cart') . '" class="action tocart"'
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->getAddToCartUrl($_product) . '"} }\'>'
. '<span>' . __('Add to Cart') . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . __('In stock') . '</span></div>' :
'<div class="stock unavailable"><span>' . __('Out of stock') . '</span></div>';
}

$info['links'] = '<div class="product links" data-role="add-to-links">'
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
. '<span>' . __('Add to Wish List') . '</span></a>'
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a></div>';
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';
$info['links'] = '<div class="product links" data-role="add-to-links">'
. '<a href="#" data-post=\'' . $this->helper('Magento\Wishlist\Helper\Data')->getAddParams($_product) . '\' class="action towishlist" data-action="add-to-wishlist">'
. '<span>' . __('Add to Wish List') . '</span></a>'
. '<a href="' . $block->getAddToCompareUrl($_product) . '" class="action tocompare">'
. '<span>' . __('Add to Compare') . '</span></a></div>';
$info['actions'] = '<div class="product action">' . $info['button'] . $info['links'] . '</div>';

if ($showDescription) {
$info['description'] = '<div class="product description">'
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
. __('Learn More') . '</a></div>';
} else {
$info['description'] = '';
}
if ($showDescription) {
$info['description'] = '<div class="product description">'
. $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description')
. ' <a href="' . $_product->getProductUrl() . '" class="action more">'
. __('Learn More') . '</a></div>';
} else {
$info['description'] = '';
}

$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
foreach ($details as $detail) {
/* @escapeNotVerified */ echo $info[$detail];
}
?>
$details = $block->getInfoOrder() ?: ['name','price','review','description','actions'];
foreach ($details as $detail) {
/* @escapeNotVerified */ echo $info[$detail];
}
?>

</div>
</div>
</div>
<?= ($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
</li>
<?php endforeach; ?>
</ol>
</div>
Expand Down

0 comments on commit 0a8e77a

Please sign in to comment.