Skip to content

Commit 33f0757

Browse files
author
vnayda
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-57963
2 parents 5de9934 + 9d0c8f9 commit 33f0757

File tree

217 files changed

+9008
-896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+9008
-896
lines changed

app/code/Magento/Backend/view/adminhtml/templates/system/shipping/applicable_country.phtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ CountryModel.prototype = {
6161
if (applyCountryElement && applyCountryElement.id) {
6262
var specifCountryElement = $(applyCountryElement.id.replace(/sallowspecific/, 'specificcountry'));
6363
var showMethodElement = $(applyCountryElement.id.replace(/sallowspecific/, 'showmethod'));
64+
// 'Use Default' checkbox of the related county list UI element
65+
var useDefaultElement = document.getElementById(specifCountryElement.id + '_inherit');
66+
6467
//var specifErrMsgElement = $(applyCountryElement.id.replace(/sallowspecific/, 'specificerrmsg'));
6568
if (specifCountryElement) {
6669
if (applyCountryElement.value == 1) {
67-
//if specific country element selected
68-
specifCountryElement.enable();
70+
// enable related country select only if its 'Use Default' checkbox is absent or is unchecked
71+
specifCountryElement.disabled = useDefaultElement ? useDefaultElement.checked : false;
6972
if (showMethodElement) {
7073
this.showElement(showMethodElement.up(1));
7174
}

app/code/Magento/Catalog/Console/Command/ImagesResizeCommand.php

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,15 @@
55
*/
66
namespace Magento\Catalog\Console\Command;
77

8-
use Magento\Catalog\Model\Product;
9-
use Magento\Catalog\Model\Product\Image\Cache as ImageCache;
10-
use Magento\Catalog\Model\Product\Image\CacheFactory as ImageCacheFactory;
11-
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
12-
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
13-
use Magento\Framework\App\State as AppState;
14-
use Magento\Framework\Exception\NoSuchEntityException;
15-
use Symfony\Component\Console\Command\Command;
16-
use Symfony\Component\Console\Input\InputInterface;
17-
use Symfony\Component\Console\Output\OutputInterface;
18-
19-
class ImagesResizeCommand extends Command
8+
class ImagesResizeCommand extends \Symfony\Component\Console\Command\Command
209
{
2110
/**
22-
* @var AppState
11+
* @var \Magento\Framework\App\State
2312
*/
2413
protected $appState;
2514

2615
/**
27-
* @var ProductCollectionFactory
16+
* @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
2817
*/
2918
protected $productCollectionFactory;
3019

@@ -34,21 +23,21 @@ class ImagesResizeCommand extends Command
3423
protected $productRepository;
3524

3625
/**
37-
* @var ImageCacheFactory
26+
* @var \Magento\Catalog\Model\Product\Image\CacheFactory
3827
*/
3928
protected $imageCacheFactory;
4029

4130
/**
42-
* @param AppState $appState
43-
* @param ProductCollectionFactory $productCollectionFactory
31+
* @param \Magento\Framework\App\State $appState
32+
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
4433
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
45-
* @param ImageCacheFactory $imageCacheFactory
34+
* @param \Magento\Catalog\Model\Product\Image\CacheFactory $imageCacheFactory
4635
*/
4736
public function __construct(
48-
AppState $appState,
49-
ProductCollectionFactory $productCollectionFactory,
37+
\Magento\Framework\App\State $appState,
38+
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
5039
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
51-
ImageCacheFactory $imageCacheFactory
40+
\Magento\Catalog\Model\Product\Image\CacheFactory $imageCacheFactory
5241
) {
5342
$this->appState = $appState;
5443
$this->productCollectionFactory = $productCollectionFactory;
@@ -69,11 +58,13 @@ protected function configure()
6958
/**
7059
* {@inheritdoc}
7160
*/
72-
protected function execute(InputInterface $input, OutputInterface $output)
73-
{
74-
$this->appState->setAreaCode('catalog');
61+
protected function execute(
62+
\Symfony\Component\Console\Input\InputInterface $input,
63+
\Symfony\Component\Console\Output\OutputInterface $output
64+
) {
65+
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
7566

76-
/** @var ProductCollection $productCollection */
67+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
7768
$productCollection = $this->productCollectionFactory->create();
7869
$productIds = $productCollection->getAllIds();
7970
if (!count($productIds)) {
@@ -85,13 +76,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
8576
try {
8677
foreach ($productIds as $productId) {
8778
try {
88-
/** @var Product $product */
79+
/** @var \Magento\Catalog\Model\Product $product */
8980
$product = $this->productRepository->getById($productId);
90-
} catch (NoSuchEntityException $e) {
81+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
9182
continue;
9283
}
9384

94-
/** @var ImageCache $imageCache */
85+
/** @var \Magento\Catalog\Model\Product\Image\Cache $imageCache */
9586
$imageCache = $this->imageCacheFactory->create();
9687
$imageCache->generate($product);
9788

app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function configure()
7878
protected function execute(InputInterface $input, OutputInterface $output)
7979
{
8080
$output->setDecorated(true);
81-
$this->appState->setAreaCode('catalog');
81+
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
8282
$connection = $this->attributeResource->getConnection();
8383
$attributeTables = $this->getAttributeTables();
8484

app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function addMediaDataToProduct(Product $product, array $mediaEntries)
7878

7979
foreach ($mediaEntries as $mediaEntry) {
8080
$mediaEntry = $this->substituteNullsWithDefaultValues($mediaEntry);
81-
$value['images'][] = $mediaEntry;
81+
$value['images'][$mediaEntry['value_id']] = $mediaEntry;
8282
}
8383
$product->setData($attrCode, $value);
8484
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ protected function _getIndexableAttributesCondition()
263263
'ca.is_filterable_in_search > 0',
264264
'ca.is_visible_in_advanced_search > 0',
265265
'ca.is_filterable > 0',
266+
// Visibility is attribute that isn't used by search, but required to determine is product should be shown
267+
"ea.attribute_code = 'visibility'"
266268
];
267269

268270
return implode(' OR ', $conditions);

app/code/Magento/Catalog/Test/Unit/Console/Command/ImagesResizeCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\State as AppState;
1515
use Magento\Framework\Exception\NoSuchEntityException;
1616
use Symfony\Component\Console\Tester\CommandTester;
17+
use \Magento\Framework\App\Area;
1718

1819
/**
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -79,7 +80,7 @@ public function testExecuteNoProducts()
7980
{
8081
$this->appState->expects($this->once())
8182
->method('setAreaCode')
82-
->with('catalog')
83+
->with(Area::AREA_GLOBAL)
8384
->willReturnSelf();
8485

8586
$this->productCollection->expects($this->once())
@@ -101,7 +102,7 @@ public function testExecute()
101102

102103
$this->appState->expects($this->once())
103104
->method('setAreaCode')
104-
->with('catalog')
105+
->with(Area::AREA_GLOBAL)
105106
->willReturnSelf();
106107

107108
$this->productCollection->expects($this->once())
@@ -142,7 +143,7 @@ public function testExecuteWithException()
142143

143144
$this->appState->expects($this->once())
144145
->method('setAreaCode')
145-
->with('catalog')
146+
->with(Area::AREA_GLOBAL)
146147
->willReturnSelf();
147148

148149
$this->productCollection->expects($this->once())

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Magento\Catalog\Model\Locator\LocatorInterface;
1010
use Magento\Ui\Component\Form;
1111
use Magento\Framework\Stdlib\ArrayManager;
12-
use Magento\Store\Model\StoreManagerInterface;
13-
use Magento\Framework\Locale\CurrencyInterface;
1412

1513
/**
1614
* Data provider for main panel of product page
@@ -26,14 +24,9 @@ class General extends AbstractModifier
2624
* @var ArrayManager
2725
*/
2826
protected $arrayManager;
29-
30-
/**
31-
* @var StoreManagerInterface
32-
*/
33-
private $storeManager;
3427

3528
/**
36-
* @var CurrencyInterface
29+
* @var \Magento\Framework\Locale\CurrencyInterface
3730
*/
3831
private $localeCurrency;
3932

@@ -82,7 +75,7 @@ protected function customizeWeightFormat(array $data)
8275
$data = $this->arrayManager->replace(
8376
$path,
8477
$data,
85-
$this->formatNumber($this->arrayManager->get($path, $data))
78+
$this->formatWeight($this->arrayManager->get($path, $data))
8679
);
8780
}
8881

@@ -105,7 +98,7 @@ protected function customizeAdvancedPriceFormat(array $data)
10598
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
10699
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
107100
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
108-
$this->formatNumber((int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]);
101+
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
109102
}
110103
}
111104

@@ -373,28 +366,12 @@ protected function customizeNameListeners(array $meta)
373366
private function getLocaleCurrency()
374367
{
375368
if ($this->localeCurrency === null) {
376-
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()->get(CurrencyInterface::class);
369+
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()
370+
->get(\Magento\Framework\Locale\CurrencyInterface::class);
377371
}
378372
return $this->localeCurrency;
379373
}
380374

381-
/**
382-
* The getter function to get the store manager for real application code
383-
*
384-
* @return \Magento\Store\Model\StoreManagerInterface
385-
*
386-
* @deprecated
387-
*/
388-
private function getStoreManager()
389-
{
390-
if ($this->storeManager === null) {
391-
$this->storeManager =
392-
\Magento\Framework\App\ObjectManager::getInstance()->get(StoreManagerInterface::class);
393-
}
394-
return $this->storeManager;
395-
}
396-
397-
398375
/**
399376
* Format price according to the locale of the currency
400377
*
@@ -407,7 +384,7 @@ protected function formatPrice($value)
407384
return null;
408385
}
409386

410-
$store = $this->getStoreManager()->getStore();
387+
$store = $this->locator->getStore();
411388
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
412389
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
413390

@@ -428,7 +405,7 @@ protected function formatNumber($value)
428405

429406
$value = (float)$value;
430407
$precision = strlen(substr(strrchr($value, "."), 1));
431-
$store = $this->getStoreManager()->getStore();
408+
$store = $this->locator->getStore();
432409
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
433410
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL,
434411
'precision' => $precision]);

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
define([
67
'jquery',
78
'Magento_Catalog/js/price-utils',
@@ -29,6 +30,7 @@ define([
2930
*/
3031
_init: function initPriceBox() {
3132
var box = this.element;
33+
3234
box.trigger('updatePrice');
3335
this.cache.displayPrices = utils.deepClone(this.options.prices);
3436
},
@@ -70,7 +72,8 @@ define([
7072
updatePrice: function updatePrice(newPrices) {
7173
var prices = this.cache.displayPrices,
7274
additionalPrice = {},
73-
pricesCode = [];
75+
pricesCode = [],
76+
priceValue, origin, finalPrice;
7477

7578
this.cache.additionalPriceObject = this.cache.additionalPriceObject || {};
7679

@@ -89,19 +92,19 @@ define([
8992
pricesCode = _.keys(additional);
9093
}
9194
_.each(pricesCode, function (priceCode) {
92-
var priceValue = additional[priceCode] || {};
95+
priceValue = additional[priceCode] || {};
9396
priceValue.amount = +priceValue.amount || 0;
9497
priceValue.adjustments = priceValue.adjustments || {};
9598

9699
additionalPrice[priceCode] = additionalPrice[priceCode] || {
97-
'amount': 0,
98-
'adjustments': {}
99-
};
100-
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0)
101-
+ priceValue.amount;
100+
'amount': 0,
101+
'adjustments': {}
102+
};
103+
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) +
104+
priceValue.amount;
102105
_.each(priceValue.adjustments, function (adValue, adCode) {
103-
additionalPrice[priceCode].adjustments[adCode] = 0
104-
+ (additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
106+
additionalPrice[priceCode].adjustments[adCode] = 0 +
107+
(additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
105108
});
106109
});
107110
});
@@ -110,23 +113,24 @@ define([
110113
this.cache.displayPrices = utils.deepClone(this.options.prices);
111114
} else {
112115
_.each(additionalPrice, function (option, priceCode) {
113-
var origin = this.options.prices[priceCode] || {},
114-
final = prices[priceCode] || {};
116+
origin = this.options.prices[priceCode] || {};
117+
finalPrice = prices[priceCode] || {};
115118
option.amount = option.amount || 0;
116119
origin.amount = origin.amount || 0;
117120
origin.adjustments = origin.adjustments || {};
118-
final.adjustments = final.adjustments || {};
121+
finalPrice.adjustments = finalPrice.adjustments || {};
119122

120-
final.amount = 0 + origin.amount + option.amount;
123+
finalPrice.amount = 0 + origin.amount + option.amount;
121124
_.each(option.adjustments, function (pa, paCode) {
122-
final.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
125+
finalPrice.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
123126
});
124127
}, this);
125128
}
126129

127130
this.element.trigger('reloadPrice');
128131
},
129132

133+
/*eslint-disable no-extra-parens*/
130134
/**
131135
* Render price unit block.
132136
*/
@@ -135,16 +139,19 @@ define([
135139
priceTemplate = mageTemplate(this.options.priceTemplate);
136140

137141
_.each(this.cache.displayPrices, function (price, priceCode) {
138-
price.final = _.reduce(price.adjustments, function(memo, amount) {
142+
price.final = _.reduce(price.adjustments, function (memo, amount) {
139143
return memo + amount;
140144
}, price.amount);
141145

142146
price.formatted = utils.formatPrice(price.final, priceFormat);
143147

144-
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));
148+
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({
149+
data: price
150+
}));
145151
}, this);
146152
},
147153

154+
/*eslint-enable no-extra-parens*/
148155
/**
149156
* Overwrites initial (default) prices object.
150157
* @param {Object} prices
@@ -177,6 +184,7 @@ define([
177184
var box = this.element,
178185
priceHolders = $('[data-price-type]', box),
179186
prices = this.options.prices;
187+
180188
this.options.productId = box.data('productId');
181189

182190
if (_.isEmpty(prices)) {
@@ -199,10 +207,7 @@ define([
199207
_setDefaultsFromPriceConfig: function _setDefaultsFromPriceConfig() {
200208
var config = this.options.priceConfig;
201209

202-
if (config) {
203-
if (+config.productId !== +this.options.productId) {
204-
return;
205-
}
210+
if (config && config.prices) {
206211
this.options.prices = config.prices;
207212
}
208213
}

0 commit comments

Comments
 (0)