Skip to content

Commit

Permalink
MC-4244: Skip URL rewrites multiplication
Browse files Browse the repository at this point in the history
-- change option name
  • Loading branch information
andimov authored and slopukhov committed May 13, 2019
1 parent d644c11 commit 855eaf0
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ private function getCategoryWithOverriddenUrlKey($storeId, Category $category)
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->config->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogUrlRewrite/Model/TableCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Magento\UrlRewrite\Model\ResourceModel\UrlRewrite;

/**
* Table Cleaner in case of switching generate_rewrites_on_save off
* Table Cleaner in case of switching generate_category_product_rewrites off
*/
class TableCleaner extends ConfigValue
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,12 @@ private function getCategoryById($categoryId, $storeId)
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_category_product_rewrites');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ private function resetUrlRewritesDataMaps($category)
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_category_product_rewrites');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ private function resetUrlRewritesDataMaps($category)
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->scopeConfig->getValue('catalog/seo/generate_category_product_rewrites');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private function getCategoryProductsUrlRewrites(
$rootCategoryId = null
) {
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
$generateProductRewrite = (bool)$this->scopeConfig->getValue('catalog/seo/generate_rewrites_on_save');
$generateProductRewrite = (bool)$this->scopeConfig->getValue('catalog/seo/generate_category_product_rewrites');

/** @var Collection $productCollection */
$productCollection = $this->productCollectionFactory->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct(
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->config->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function ($value) {
public function testGenerationForGlobalScope()
{
$this->configMock->expects($this->any())->method('getValue')
->with('catalog/seo/generate_rewrites_on_save')
->with('catalog/seo/generate_category_product_rewrites')
->willReturn('1');
$product = $this->createMock(\Magento\Catalog\Model\Product::class);
$product->expects($this->any())->method('getStoreId')->will($this->returnValue(null));
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
<label>Create Permanent Redirect for URLs if URL Key Changed</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="generate_rewrites_on_save" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Generate URL Rewrites for Products in Categories</label>
<field id="generate_category_product_rewrites" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Generate "category/product" URL Rewrites</label>
<backend_model>Magento\CatalogUrlRewrite\Model\TableCleaner</backend_model>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
<![CDATA[<strong style="color:red">Warning!</strong> Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.]]>
</comment>
<frontend_class>generate_rewrites_on_save</frontend_class>
<frontend_class>generate_category_product_rewrites</frontend_class>
</field>
</group>
</section>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogUrlRewrite/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<default>
<catalog>
<seo>
<generate_rewrites_on_save>1</generate_rewrites_on_save>
<generate_category_product_rewrites>1</generate_category_product_rewrites>
</seo>
</catalog>
</default>
Expand Down
5 changes: 1 addition & 4 deletions app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@
"Product URL Suffix","Product URL Suffix"
"Use Categories Path for Product URLs","Use Categories Path for Product URLs"
"Create Permanent Redirect for URLs if URL Key Changed","Create Permanent Redirect for URLs if URL Key Changed"
"Generate URL Rewrites for Products in Categories","Generate URL Rewrites for Products in Categories"
"Turn off "category/products" URL rewrites?","Turn off "category/products" URL rewrites?"
"Turning off automatic generation of "category/products" URL rewrites will result in permanent removal of all the currently existing “category/product” type URL rewrites without an ability to restore them back. This may potentially cause unresolved “category/product” type URL conflicts which you have to resolve by creating a URL rewrite manually.","Turning off automatic generation of "category/products" URL rewrites will result in permanent removal of all the currently existing “category/product” type URL rewrites without an ability to restore them back. This may potentially cause unresolved “category/product” type URL conflicts which you have to resolve by creating a URL rewrite manually."
"Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.","Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them."
"Generate "category/product" URL Rewrites","Generate "category/product" URL Rewrites"
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<see userInput="Hello CMS Page!" stepKey="seeContent"/>
<!--see widget on Storefront-->
<see userInput="$$createPreReqCategory.name$$" stepKey="seeCategoryLink"/>
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 0" stepKey="disableGenerateUrlRewrite"/>
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 0" stepKey="disableGenerateUrlRewrite"/>
<amOnPage url="{{_defaultCmsPage.identifier}}" stepKey="amOnPageTestPage2"/>
<waitForPageLoad stepKey="wait6" />
<see userInput="Hello CMS Page!" stepKey="seeContent2"/>
Expand All @@ -76,7 +76,7 @@
<after>
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCatalog" />
<actionGroup ref="DisabledWYSIWYG" stepKey="disableWYSIWYG"/>
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 1" stepKey="enableGenerateUrlRewrite"/>
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="enableGenerateUrlRewrite"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
</test>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<!--see widget on Storefront-->
<see userInput="Hello CMS Page!" stepKey="seeContent"/>
<see userInput="$$createPreReqProduct.name$$" stepKey="seeProductLink"/>
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 0" stepKey="disableGenerateUrlRewrite"/>
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 0" stepKey="disableGenerateUrlRewrite"/>
<amOnPage url="{{_defaultCmsPage.identifier}}" stepKey="amOnPageTestPage2"/>
<waitForPageLoad stepKey="wait8" />
<!--see widget on Storefront-->
Expand All @@ -83,7 +83,7 @@
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCatalog" />
<deleteData createDataKey="createPreReqProduct" stepKey="deletePreReqProduct" />
<actionGroup ref="DisabledWYSIWYG" stepKey="disableWYSIWYG"/>
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 1" stepKey="enableGenerateUrlRewrite"/>
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="enableGenerateUrlRewrite"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
</test>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<element name="flatCatalogProduct" type="select" selector="#catalog_frontend_flat_catalog_product"/>
<element name="seo" type="button" selector="#catalog_seo-head"/>
<element name="CheckIfSeoTabExpand" type="button" selector="#catalog_seo-head:not(.open)"/>
<element name="GenerateUrlRewrites" type="select" selector="#catalog_seo_generate_rewrites_on_save"/>
<element name="GenerateUrlRewrites" type="select" selector="#catalog_seo_generate_category_product_rewrites"/>
<element name="successMessage" type="text" selector="#messages"/>
</section>
<section name="GenerateUrlRewritesConfirm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ require([
adminSystemConfig.navigateToElement(<?php echo /* @noEscape */ $block->getConfigSearchParamsJson(); ?>);

//confirmation for removing category/product URL rewrites
jQuery('select.generate_rewrites_on_save').on('change', function(event){
jQuery('select.generate_category_product_rewrites').on('change', function(event){
if (this.value == 0) {
confirmation({
title: $t('Turn off "category/products" URL rewrites?'),
content: $t('Turning off automatic generation of "category/products" URL rewrites will result in permanent removal of all the currently existing “category/product” type URL rewrites without an ability to restore them back. ' +
'This may potentially cause unresolved “category/product” type URL conflicts which you have to resolve by creating a URL rewrite manually.'),
actions: {
cancel: function () {
jQuery('select.generate_rewrites_on_save').val(1);
jQuery('select.generate_category_product_rewrites').val(1);
return false;
},
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/UrlRewrite/Model/CompositeUrlFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public function __construct(
}

/**
* Check config value of generate_rewrites_on_save
* Check config value of generate_category_product_rewrites
*
* @return bool
*/
private function isCategoryRewritesEnabled()
{
return (bool)$this->config->getValue('catalog/seo/generate_rewrites_on_save');
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
<group value="urlRewrite"/>
</annotations>
<before>
<!-- Set the configuration to generate URL rewrie for Products on Category Save to Yes (default)-->
<comment userInput="Enable SEO configuration setting to generate URL Rewrite on Category save " stepKey="commentEnableUrlRewriteConfig" />
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 1" stepKey="enableGenerateUrlRewrite"/>
<!-- Set the configuration for Generate "category/product" URL Rewrites to Yes (default)-->
<comment userInput="Enable SEO configuration setting to generate category/product URL Rewrites" stepKey="commentEnableUrlRewriteConfig" />
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="enableGenerateUrlRewrite"/>
<!--Flush cache-->
<magentoCLI command="cache:flush" stepKey="cleanCache1"/>

Expand All @@ -144,9 +144,9 @@
<field key="name">category-admin</field>
</createData>

<!-- Set the configuration to generate URL rewrie for Products on Category Save to No-->
<comment userInput="Disable SEO configuration setting to generate URL Rewrite on Category save " stepKey="commentDisableUrlRewriteConfig" />
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 0" stepKey="disableGenerateUrlRewrite"/>
<!-- Set the configuration for Generate "category/product" URL Rewrites to No-->
<comment userInput="Disable SEO configuration setting to generate category/product URL Rewrites" stepKey="commentDisableUrlRewriteConfig" />
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 0" stepKey="disableGenerateUrlRewrite"/>
<!--Flush cache-->
<magentoCLI command="cache:flush" stepKey="cleanCache"/>
</before>
Expand All @@ -164,7 +164,7 @@
<argument name="customStore" value="customStoreNLNotUnique"/>
</actionGroup>
<actionGroup ref="logout" stepKey="logout"/>
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 1" stepKey="resetConfigurationSetting"/>
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="resetConfigurationSetting"/>
<!--Flush cache-->
<magentoCLI command="cache:flush" stepKey="cleanCache2"/>
</after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<!-- Preconditions-->
<before>
<!-- Set the configuration to generate URL rewrie for Products on Category Save-->
<comment userInput="Enable config to generate URL Rewrite on Category save " stepKey="commentEnableConfig" />
<magentoCLI command="config:set catalog/seo/generate_rewrites_on_save 1" stepKey="enableGenerateUrlRewrite"/>
<!-- Set the configuration for Generate "category/product" URL Rewrites-->
<comment userInput="Enable config to generate category/product URL Rewrites" stepKey="commentEnableConfig" />
<magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="enableGenerateUrlRewrite"/>
<!--Flush cache-->
<magentoCLI command="cache:flush" stepKey="cleanCache1"/>
<!-- Create 4 categories -->
Expand Down Expand Up @@ -73,7 +73,7 @@
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessageAfterSaved"/>

<!-- 5. Set the configuration to generate URL rewrie for Products on Category Save to No-->
<!-- 5. Set the configuration for Generate "category/product" URL Rewrites to No-->
<amOnPage url="{{CatalogConfigPage.url}}" stepKey="amOnCatalogConfigPage"/>
<conditionalClick selector="{{CatalogSection.seo}}" dependentSelector="{{CatalogSection.CheckIfSeoTabExpand}}" visible="true" stepKey="expandSeoTab" />
<waitForElementVisible selector="{{CatalogSection.GenerateUrlRewrites}}" stepKey="GenerateUrlRewritesSelect"/>
Expand Down
Loading

0 comments on commit 855eaf0

Please sign in to comment.