Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit ae62931

Browse files
committed
Merge remote-tracking branch 'remotes/origin/2.2-develop' into issues/12374
2 parents a847d89 + b1cc3ea commit ae62931

File tree

69 files changed

+1933
-280
lines changed

Some content is hidden

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

69 files changed

+1933
-280
lines changed

.github/.htaccess

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<IfVersion < 2.4>
2+
order allow,deny
3+
deny from all
4+
</IfVersion>
5+
<IfVersion >= 2.4>
6+
Require all denied
7+
</IfVersion>
8+

.github/CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/
File renamed without changes.
File renamed without changes.
File renamed without changes.

.htaccess

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,6 @@
274274
Require all denied
275275
</IfVersion>
276276
</Files>
277-
<Files CONTRIBUTING.md>
278-
<IfVersion < 2.4>
279-
order allow,deny
280-
deny from all
281-
</IfVersion>
282-
<IfVersion >= 2.4>
283-
Require all denied
284-
</IfVersion>
285-
</Files>
286277
<Files COPYING.txt>
287278
<IfVersion < 2.4>
288279
order allow,deny

.htaccess.sample

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@
251251
Require all denied
252252
</IfVersion>
253253
</Files>
254-
<Files CONTRIBUTING.md>
255-
<IfVersion < 2.4>
256-
order allow,deny
257-
deny from all
258-
</IfVersion>
259-
<IfVersion >= 2.4>
260-
Require all denied
261-
</IfVersion>
262-
</Files>
263254
<Files COPYING.txt>
264255
<IfVersion < 2.4>
265256
order allow,deny

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Catalog\Console\Command;
77

8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
811
class ImagesResizeCommand extends \Symfony\Component\Console\Command\Command
912
{
1013
/**
@@ -58,10 +61,8 @@ protected function configure()
5861
/**
5962
* {@inheritdoc}
6063
*/
61-
protected function execute(
62-
\Symfony\Component\Console\Input\InputInterface $input,
63-
\Symfony\Component\Console\Output\OutputInterface $output
64-
) {
64+
protected function execute(InputInterface $input, OutputInterface $output)
65+
{
6566
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
6667

6768
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
@@ -73,6 +74,7 @@ protected function execute(
7374
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
7475
}
7576

77+
$errorMessage = '';
7678
try {
7779
foreach ($productIds as $productId) {
7880
try {
@@ -82,9 +84,13 @@ protected function execute(
8284
continue;
8385
}
8486

85-
/** @var \Magento\Catalog\Model\Product\Image\Cache $imageCache */
86-
$imageCache = $this->imageCacheFactory->create();
87-
$imageCache->generate($product);
87+
try {
88+
/** @var \Magento\Catalog\Model\Product\Image\Cache $imageCache */
89+
$imageCache = $this->imageCacheFactory->create();
90+
$imageCache->generate($product);
91+
} catch (\Magento\Framework\Exception\RuntimeException $e) {
92+
$errorMessage = $e->getMessage();
93+
}
8894

8995
$output->write(".");
9096
}
@@ -95,6 +101,12 @@ protected function execute(
95101
}
96102

97103
$output->write("\n");
98-
$output->writeln("<info>Product images resized successfully</info>");
104+
$output->writeln("<info>Product images resized successfully.</info>");
105+
106+
if ($errorMessage !== '') {
107+
$output->writeln("<comment>{$errorMessage}</comment>");
108+
}
109+
110+
return 0;
99111
}
100112
}

app/code/Magento/Catalog/Model/Indexer/Product/Eav/AbstractAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ protected function syncData($indexer, $destinationTable, $ids)
143143
protected function processRelations($indexer, $ids, $onlyParents = false)
144144
{
145145
$parentIds = $indexer->getRelationsByChild($ids);
146+
$parentIds = array_unique(array_merge($parentIds, $ids));
146147
$childIds = $onlyParents ? [] : $indexer->getRelationsByParent($parentIds);
147148
return array_unique(array_merge($ids, $childIds, $parentIds));
148149
}

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
118118
$attribute->setAttributeId($existingModel->getAttributeId());
119119
$attribute->setIsUserDefined($existingModel->getIsUserDefined());
120120
$attribute->setFrontendInput($existingModel->getFrontendInput());
121+
if ($attribute->getIsUserDefined()) {
122+
$this->processAttributeData($attribute);
123+
}
121124

122125
if (is_array($attribute->getFrontendLabels())) {
123126
$defaultFrontendLabel = $attribute->getDefaultFrontendLabel();
@@ -156,15 +159,7 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
156159
$this->validateCode($attribute->getAttributeCode());
157160
$this->validateFrontendInput($attribute->getFrontendInput());
158161

159-
$attribute->setBackendType(
160-
$attribute->getBackendTypeByInput($attribute->getFrontendInput())
161-
);
162-
$attribute->setSourceModel(
163-
$this->productHelper->getAttributeSourceModelByInputType($attribute->getFrontendInput())
164-
);
165-
$attribute->setBackendModel(
166-
$this->productHelper->getAttributeBackendModelByInputType($attribute->getFrontendInput())
167-
);
162+
$this->processAttributeData($attribute);
168163
$attribute->setEntityTypeId(
169164
$this->eavConfig
170165
->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
@@ -275,4 +270,23 @@ protected function validateFrontendInput($frontendInput)
275270
throw InputException::invalidFieldValue('frontend_input', $frontendInput);
276271
}
277272
}
273+
274+
/**
275+
* Process attribute data based on attribute frontend input type.
276+
*
277+
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
278+
* @return void
279+
*/
280+
private function processAttributeData(\Magento\Catalog\Api\Data\ProductAttributeInterface $attribute)
281+
{
282+
$attribute->setBackendType(
283+
$attribute->getBackendTypeByInput($attribute->getFrontendInput())
284+
);
285+
$attribute->setSourceModel(
286+
$this->productHelper->getAttributeSourceModelByInputType($attribute->getFrontendInput())
287+
);
288+
$attribute->setBackendModel(
289+
$this->productHelper->getAttributeBackendModelByInputType($attribute->getFrontendInput())
290+
);
291+
}
278292
}

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?php
22
/**
3-
* Catalog product copier. Creates product duplicate
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Catalog\Model\Product;
97

108
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\Product;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\EntityManager\MetadataPool;
12+
use Magento\Catalog\Model\ProductFactory;
13+
use Magento\Catalog\Model\Product\Option\Repository as OptionRepository;
1114

15+
/**
16+
* Catalog product copier. Creates product duplicate
17+
*/
1218
class Copier
1319
{
1420
/**
15-
* @var Option\Repository
21+
* @var OptionRepository
1622
*/
1723
protected $optionRepository;
1824

@@ -22,22 +28,22 @@ class Copier
2228
protected $copyConstructor;
2329

2430
/**
25-
* @var \Magento\Catalog\Model\ProductFactory
31+
* @var ProductFactory
2632
*/
2733
protected $productFactory;
2834

2935
/**
30-
* @var \Magento\Framework\EntityManager\MetadataPool
36+
* @var MetadataPool
3137
*/
3238
protected $metadataPool;
3339

3440
/**
3541
* @param CopyConstructorInterface $copyConstructor
36-
* @param \Magento\Catalog\Model\ProductFactory $productFactory
42+
* @param ProductFactory $productFactory
3743
*/
3844
public function __construct(
3945
CopyConstructorInterface $copyConstructor,
40-
\Magento\Catalog\Model\ProductFactory $productFactory
46+
ProductFactory $productFactory
4147
) {
4248
$this->productFactory = $productFactory;
4349
$this->copyConstructor = $copyConstructor;
@@ -46,18 +52,16 @@ public function __construct(
4652
/**
4753
* Create product duplicate
4854
*
49-
* @param \Magento\Catalog\Model\Product $product
50-
* @return \Magento\Catalog\Model\Product
55+
* @param Product $product
56+
* @return Product
5157
*/
52-
public function copy(\Magento\Catalog\Model\Product $product)
58+
public function copy(Product $product)
5359
{
5460
$product->getWebsiteIds();
5561
$product->getCategoryIds();
5662

57-
/** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
5863
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
5964

60-
/** @var \Magento\Catalog\Model\Product $duplicate */
6165
$duplicate = $this->productFactory->create();
6266
$productData = $product->getData();
6367
$productData = $this->removeStockItem($productData);
@@ -83,6 +87,7 @@ public function copy(\Magento\Catalog\Model\Product $product)
8387
$duplicate->save();
8488
$isDuplicateSaved = true;
8589
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
90+
} catch (\Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException $e) {
8691
}
8792
} while (!$isDuplicateSaved);
8893
$this->getOptionRepository()->duplicate($product, $duplicate);
@@ -94,27 +99,25 @@ public function copy(\Magento\Catalog\Model\Product $product)
9499
}
95100

96101
/**
97-
* @return Option\Repository
102+
* @return OptionRepository
98103
* @deprecated 101.0.0
99104
*/
100105
private function getOptionRepository()
101106
{
102107
if (null === $this->optionRepository) {
103-
$this->optionRepository = \Magento\Framework\App\ObjectManager::getInstance()
104-
->get(\Magento\Catalog\Model\Product\Option\Repository::class);
108+
$this->optionRepository = ObjectManager::getInstance()->get(OptionRepository::class);
105109
}
106110
return $this->optionRepository;
107111
}
108112

109113
/**
110-
* @return \Magento\Framework\EntityManager\MetadataPool
114+
* @return MetadataPool
111115
* @deprecated 101.0.0
112116
*/
113117
private function getMetadataPool()
114118
{
115119
if (null === $this->metadataPool) {
116-
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
117-
->get(\Magento\Framework\EntityManager\MetadataPool::class);
120+
$this->metadataPool = ObjectManager::getInstance()->get(MetadataPool::class);
118121
}
119122
return $this->metadataPool;
120123
}

0 commit comments

Comments
 (0)