Skip to content

Commit 2312b77

Browse files
Merge branch 'develop' of https://github.com/magento/magento2ce into MPI-PR206
2 parents a8ac7d5 + 8545fd8 commit 2312b77

File tree

46 files changed

+741
-120
lines changed

Some content is hidden

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

46 files changed

+741
-120
lines changed

app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
data-validate="{required:true}"
4444
value=""
4545
placeholder="<?php /* @escapeNotVerified */ echo __('password') ?>"
46-
autocomplete="off"
46+
autocomplete="new-password"
4747
/>
4848
</div>
4949
</div>

app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<fieldset class="admin__fieldset password-box-container">
7474
<div class="admin__field field _required">
7575
<label for="password" class="admin__field-label"><span><?php /* @escapeNotVerified */ echo __('User Password')?></span></label>
76-
<div class="admin__field-control"><input type="password" name="password" id="password" class="admin__control-text required-entry" autocomplete="off"></div>
76+
<div class="admin__field-control"><input type="password" name="password" id="password" class="admin__control-text required-entry" autocomplete="new-password"></div>
7777
</div>
7878

7979
<div class="admin__field field maintenance-checkbox-container">
@@ -119,7 +119,7 @@
119119
<span><?php /* @escapeNotVerified */ echo __('FTP Password') ?></span>
120120
</label>
121121
<div class="admin__field-control">
122-
<input type="password" class="admin__control-text" name="ftp_pass" id="ftp_pass" autocomplete="off">
122+
<input type="password" class="admin__control-text" name="ftp_pass" id="ftp_pass" autocomplete="new-password">
123123
</div>
124124
</div>
125125
<div class="admin__field field">

app/code/Magento/Catalog/view/adminhtml/ui_component/design_config_form.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<formElements>
2828
<fileUploader>
2929
<settings>
30-
<allowedExtensions>jpg jpeg gif png svg</allowedExtensions>
30+
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
3131
<maxFileSize>2097152</maxFileSize>
3232
<uploaderConfig>
3333
<param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
@@ -87,7 +87,7 @@
8787
<formElements>
8888
<fileUploader>
8989
<settings>
90-
<allowedExtensions>jpg jpeg gif png svg</allowedExtensions>
90+
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
9191
<maxFileSize>2097152</maxFileSize>
9292
<uploaderConfig>
9393
<param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
@@ -147,7 +147,7 @@
147147
<formElements>
148148
<fileUploader>
149149
<settings>
150-
<allowedExtensions>jpg jpeg gif png svg</allowedExtensions>
150+
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
151151
<maxFileSize>2097152</maxFileSize>
152152
<uploaderConfig>
153153
<param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,15 @@ protected function _saveLinks()
12281228
'linked_product_id' => $linkedId,
12291229
'link_type_id' => $linkId,
12301230
];
1231-
if (!empty($linkPositions[$linkedKey])) {
1232-
$positionRows[] = [
1233-
'link_id' => $productLinkKeys[$linkKey],
1234-
'product_link_attribute_id' => $positionAttrId[$linkId],
1235-
'value' => $linkPositions[$linkedKey],
1236-
];
1237-
}
1238-
$nextLinkId++;
12391231
}
1232+
if (!empty($linkPositions[$linkedKey])) {
1233+
$positionRows[] = [
1234+
'link_id' => $productLinkKeys[$linkKey],
1235+
'product_link_attribute_id' => $positionAttrId[$linkId],
1236+
'value' => $linkPositions[$linkedKey],
1237+
];
1238+
}
1239+
$nextLinkId++;
12401240
}
12411241
}
12421242
}

app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
}
4242

4343
/**
44-
* Generate list based on categories
44+
* Generate product rewrites for anchor categories
4545
*
4646
* @param int $storeId
4747
* @param Product $product

app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, Ur
3030
}
3131

3232
/**
33-
* Generate list based on store view
33+
* Generate product rewrites without categories
3434
*
3535
* @param int $storeId
3636
* @param Product $product

app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, Ur
3131
}
3232

3333
/**
34-
* Generate list based on categories
34+
* Generate product rewrites with categories
3535
*
3636
* @param int $storeId
3737
* @param Product $product

app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogUrlRewrite\Model\Product;
77

88
use Magento\Catalog\Model\Category;
9+
use Magento\Catalog\Model\CategoryRepository;
910
use Magento\Catalog\Model\Product;
1011
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1112
use Magento\UrlRewrite\Model\OptionProvider;
@@ -56,19 +57,24 @@ class CurrentUrlRewritesRegenerator
5657
/** @var \Magento\UrlRewrite\Model\MergeDataProvider */
5758
private $mergeDataProviderPrototype;
5859

60+
/** @var CategoryRepository */
61+
private $categoryRepository;
62+
5963
/**
6064
* @param UrlFinderInterface $urlFinder
6165
* @param ProductUrlPathGenerator $productUrlPathGenerator
6266
* @param UrlRewriteFactory $urlRewriteFactory
6367
* @param UrlRewriteFinder|null $urlRewriteFinder
6468
* @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory
69+
* @param CategoryRepository|null $categoryRepository
6570
*/
6671
public function __construct(
6772
UrlFinderInterface $urlFinder,
6873
ProductUrlPathGenerator $productUrlPathGenerator,
6974
UrlRewriteFactory $urlRewriteFactory,
7075
UrlRewriteFinder $urlRewriteFinder = null,
71-
MergeDataProviderFactory $mergeDataProviderFactory = null
76+
MergeDataProviderFactory $mergeDataProviderFactory = null,
77+
CategoryRepository $categoryRepository = null
7278
) {
7379
$this->urlFinder = $urlFinder;
7480
$this->productUrlPathGenerator = $productUrlPathGenerator;
@@ -78,11 +84,12 @@ public function __construct(
7884
if (!isset($mergeDataProviderFactory)) {
7985
$mergeDataProviderFactory = ObjectManager::getInstance()->get(MergeDataProviderFactory::class);
8086
}
87+
$this->categoryRepository = $categoryRepository ?: ObjectManager::getInstance()->get(CategoryRepository::class);
8188
$this->mergeDataProviderPrototype = $mergeDataProviderFactory->create();
8289
}
8390

8491
/**
85-
* Generate list based on current rewrites
92+
* Generate product rewrites based on current rewrites without anchor categories
8693
*
8794
* @param int $storeId
8895
* @param Product $product
@@ -115,6 +122,52 @@ public function generate($storeId, Product $product, ObjectRegistry $productCate
115122
return $mergeDataProvider->getData();
116123
}
117124

125+
/**
126+
* Generate product rewrites for anchor categories based on current rewrites
127+
*
128+
* @param int $storeId
129+
* @param Product $product
130+
* @param ObjectRegistry $productCategories
131+
* @param int|null $rootCategoryId
132+
* @return UrlRewrite[]
133+
*/
134+
public function generateAnchor(
135+
$storeId,
136+
Product $product,
137+
ObjectRegistry $productCategories,
138+
$rootCategoryId = null
139+
) {
140+
$anchorCategoryIds = [];
141+
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
142+
143+
$currentUrlRewrites = $this->urlRewriteFinder->findAllByData(
144+
$product->getEntityId(),
145+
$storeId,
146+
ProductUrlRewriteGenerator::ENTITY_TYPE,
147+
$rootCategoryId
148+
);
149+
150+
foreach ($productCategories->getList() as $productCategory) {
151+
$anchorCategoryIds = array_merge($productCategory->getAnchorsAbove(), $anchorCategoryIds);
152+
}
153+
154+
foreach ($currentUrlRewrites as $currentUrlRewrite) {
155+
$metadata = $currentUrlRewrite->getMetadata();
156+
if (isset($metadata['category_id']) && $metadata['category_id'] > 0) {
157+
$category = $this->categoryRepository->get($metadata['category_id'], $storeId);
158+
if (in_array($category->getId(), $anchorCategoryIds)) {
159+
$mergeDataProvider->merge(
160+
$currentUrlRewrite->getIsAutogenerated()
161+
? $this->generateForAutogenerated($currentUrlRewrite, $storeId, $category, $product)
162+
: $this->generateForCustom($currentUrlRewrite, $storeId, $category, $product)
163+
);
164+
}
165+
}
166+
}
167+
168+
return $mergeDataProvider->getData();
169+
}
170+
118171
/**
119172
* @param UrlRewrite $url
120173
* @param int $storeId

app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ public function generateForSpecificStoreView($storeId, $productCategories, Produ
171171
$mergeDataProvider->merge(
172172
$this->anchorUrlRewriteGenerator->generate($storeId, $product, $productCategories)
173173
);
174-
174+
$mergeDataProvider->merge(
175+
$this->currentUrlRewritesRegenerator->generateAnchor(
176+
$storeId,
177+
$product,
178+
$productCategories,
179+
$rootCategoryId
180+
)
181+
);
175182
return $mergeDataProvider->getData();
176183
}
177184

app/code/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public function __construct(
8080
public function generateProductUrlRewrites(\Magento\Catalog\Model\Category $category)
8181
{
8282
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
83-
$this->isSkippedProduct = [];
83+
$this->isSkippedProduct[$category->getEntityId()] = [];
8484
$saveRewriteHistory = $category->getData('save_rewrites_history');
8585
$storeId = $category->getStoreId();
8686
if ($category->getAffectedProductIds()) {
87-
$this->isSkippedProduct = $category->getAffectedProductIds();
87+
$this->isSkippedProduct[$category->getEntityId()] = $category->getAffectedProductIds();
8888
$collection = $this->productCollectionFactory->create()
8989
->setStoreId($storeId)
9090
->addIdFilter($category->getAffectedProductIds())
@@ -137,17 +137,25 @@ public function getCategoryProductsUrlRewrites(
137137
$rootCategoryId = null
138138
) {
139139
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
140+
140141
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
141-
$productCollection = $category->getProductCollection()
142+
$productCollection = $this->productCollectionFactory->create();
143+
144+
$productCollection->addCategoriesFilter(['eq' => [$category->getEntityId()]])
145+
->setStoreId($storeId)
142146
->addAttributeToSelect('name')
143147
->addAttributeToSelect('visibility')
144148
->addAttributeToSelect('url_key')
145149
->addAttributeToSelect('url_path');
150+
146151
foreach ($productCollection as $product) {
147-
if (in_array($product->getId(), $this->isSkippedProduct)) {
152+
if (
153+
isset($this->isSkippedProduct[$category->getEntityId()]) &&
154+
in_array($product->getId(), $this->isSkippedProduct[$category->getEntityId()])
155+
) {
148156
continue;
149157
}
150-
$this->isSkippedProduct[] = $product->getId();
158+
$this->isSkippedProduct[$category->getEntityId()][] = $product->getId();
151159
$product->setStoreId($storeId);
152160
$product->setData('save_rewrites_history', $saveRewriteHistory);
153161
$mergeDataProvider->merge(

0 commit comments

Comments
 (0)