Skip to content

Commit

Permalink
Add class Mage_Adminhtml_Model_System_Config_Backend_Seo
Browse files Browse the repository at this point in the history
to change category flas and product flat indexers status to require_reindex when configuration changed
  • Loading branch information
MarcinNowakMacopedia committed Aug 19, 2022
1 parent 8341d2c commit e33773c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
46 changes: 46 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Seo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


class Mage_Adminhtml_Model_System_Config_Backend_Seo extends Mage_Core_Model_Config_Data
{
/**
* Refresh categories and products url rewrites if configuration was changed
*/
protected function _afterSave()
{
if ($this->isValueChanged()) {
Mage::getModel('index/indexer')
->getProcessByCode(Mage_Catalog_Helper_Category_Flat::CATALOG_CATEGORY_FLAT_PROCESS_CODE)
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);

Mage::getModel('index/indexer')
->getProcessByCode(Mage_Catalog_Helper_Product_Flat::CATALOG_FLAT_PROCESS_CODE)
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
}
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
class Mage_Adminhtml_Model_System_Config_Backend_Seo_Product extends Mage_Core_Model_Config_Data
{
/**
* Refresh category url rewrites if configuration was changed
* Refresh products url rewrites if configuration was changed
*
* @return $this
*/
protected function _afterSave()
{
/**
* Index model responsible for rewrites index
*/
// if ($this->isValueChanged()) {
// Mage::getSingleton('catalog/url')->refreshRewrites();
// }
if ($this->isValueChanged()) {
Mage::getModel('index/indexer')
->getProcessByCode(Mage_Catalog_Helper_Product_Flat::CATALOG_FLAT_PROCESS_CODE)
->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
}

return $this;
}
}
3 changes: 1 addition & 2 deletions app/code/core/Mage/Catalog/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
</product_url_suffix>
<product_use_categories translate="label">
<label>Use Categories Path for Product URLs</label>
<comment>Changing this option requires full reindex of "catalog_url"</comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<backend_model>adminhtml/system_config_backend_seo_product</backend_model>
Expand All @@ -279,9 +278,9 @@
</product_use_categories>
<create_url_for_disabled translate="label">
<label>Generate URL rewrites for disabled categories and products</label>
<comment>Changing this option requires full reindex of "catalog_url"</comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<backend_model>adminhtml/system_config_backend_seo</backend_model>
<sort_order>4</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
Expand Down

0 comments on commit e33773c

Please sign in to comment.