Method inside InstallData.php/UpgradeData.php to remove suffix from product and catalog pages:
public function removeSuffix()
{
$this->_config->saveConfig('catalog/seo/product_url_suffix', null, 'default', 0);
$this->_config->saveConfig('catalog/seo/category_url_suffix', null, 'default', 0);
}
As you can see in screenshots below, in backend the changes have been made and the core_config_data
table has the fields that it would have if it was done manually in backend, but in url_rewrite
table paths don't get updated.
Product and category links still show up as e.g. http://test.dev/gear/bags.html
with the suffix.
I have done sudo bin/magento indexer:reindex
and also tried flushing cache.
The suffix fields in backend are changed after running script:
The core_config_data
table has the fields that would normally be there if it was done manually:
The url_rewrite
table paths are not being changed: