SEO is the most important thing to have on a website and opencart doesn't have good SEO defaults. This will add validation to product upload.
Features
1. SEO URL is required
2. SEO URL should have no special characters and space
Features
1. SEO URL is required
2. SEO URL should have no special characters and space
XML:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Product Upload SEO URL Enhancements</name>
<version>1.0</version>
<author>Jay Mendrez</author>
<link>https://github.com/zerdnem</link>
<code>seo_url_validation</code>
<description>Product upload SEO URL validation</description>
<file path="admin/view/template/catalog/product_form.twig">
<operation>
<search><![CDATA[
{% if error_keyword[store.store_id][language.language_id] %}
]]></search>
<add position="before">
<![CDATA[
{% if error_seo_url_empty[store.store_id][language.language_id] %}
<div class="text-danger">{{ error_seo_url_empty[store.store_id][language.language_id] }}</div>
{% endif %}
{% if error_special_chars[store.store_id][language.language_id] %}
<div class="text-danger">{{ error_special_chars[store.store_id][language.language_id] }}</div>
{% endif %}
]]>
</add>
</operation>
</file>
<file path="admin/controller/catalog/product.php">
<operation>
<search><![CDATA[
protected function validateDelete() {
]]></search>
<add position="before">
<![CDATA[
protected function checkSpecialChars($txt) {
return strpbrk($txt, "_ #$%^&*()+=[]';,./{}|:<>?~");
}
]]>
</add>
</operation>
<operation>
<search><![CDATA[
if (isset($this->error['keyword'])) {
]]></search>
<add position="before">
<![CDATA[
if (isset($this->error['seo_url_empty'])) {
$data['error_seo_url_empty'] = $this->error['seo_url_empty'];
} else {
$data['error_seo_url_empty'] = array();
}
if (isset($this->error['seo_special_chars'])) {
$data['error_special_chars'] = $this->error['seo_special_chars'];
} else {
$data['error_special_chars'] = '';
}
]]>
</add>
</operation>
<operation>
<search><![CDATA[
foreach ($language as $language_id => $keyword) {
]]></search>
<add position="after">
<![CDATA[
if (empty($keyword)) {
$this->error['seo_url_empty'][$store_id][$language_id] = $this->language->get('error_seo_url_empty');
}
]]>
</add>
</operation>
<operation>
<search><![CDATA[
if (count(array_keys($language, $keyword)) > 1) {
]]></search>
<add position="before">
<![CDATA[
if ($this->checkSpecialChars($keyword)) {
$this->error['seo_special_chars'][$store_id][$language_id] = $this->language->get('error_special_chars');
}
]]>
</add>
</operation>
</file>
<file path="admin/language/en-gb/catalog/product.php">
<operation>
<search><![CDATA[
$_['error_warning'] = 'Warning: Please check the form carefully for errors!';
]]></search>
<add position="before">
<![CDATA[
$_['error_seo_url_empty'] = 'Please add SEO URL!';
$_['error_special_chars'] = 'SEO URL must not use spaces and special characters!';
]]>
</add>
</operation>
</file>
</modification>