Skip to content

Commit 9881180

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/develop' into MAGETWO-52837-command-return-nonzero-on-failure
2 parents 11e0fa7 + 8bf902a commit 9881180

File tree

68 files changed

+2048
-414
lines changed

Some content is hidden

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

68 files changed

+2048
-414
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/CatalogImportExport/Model/Import/Uploader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public function move($fileName, $renameFileOff = false)
155155

156156
$filePath = $this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName);
157157
$this->_setUploadFile($filePath);
158-
$result = $this->save($this->getDestDir());
158+
$destDir = $this->_directory->getAbsolutePath($this->getDestDir());
159+
$result = $this->save($destDir);
159160
$result['name'] = self::getCorrectFileName($result['name']);
160161
return $result;
161162
}
@@ -305,11 +306,10 @@ protected function _moveFile($tmpPath, $destPath)
305306
$tmpRealPath = $this->_directory->getDriver()->getRealPath(
306307
$this->_directory->getAbsolutePath($tmpPath)
307308
);
308-
$destinationRealPath = $this->_directory->getDriver()->getRealPath(
309-
$this->_directory->getAbsolutePath($destPath)
310-
);
309+
$destinationRealPath = $this->_directory->getDriver()->getRealPath($destPath);
310+
$relativeDestPath = $this->_directory->getRelativePath($destPath);
311311
$isSameFile = $tmpRealPath === $destinationRealPath;
312-
return $isSameFile ?: $this->_directory->copyFile($tmpPath, $destPath);
312+
return $isSameFile ?: $this->_directory->copyFile($tmpPath, $relativeDestPath);
313313
} else {
314314
return false;
315315
}

0 commit comments

Comments
 (0)