- Posts: 101
- Thank you received: 0
Saving Category with the same or no alias
10 years 1 month ago - 10 years 1 month ago #248107
by onyc
Saving Category with the same or no alias was created by onyc
In my test site: we get the following error when we try to save a category “An element with the same alias already exists”
We noticed because we have same subcategory in two different categories. In older version we can use the same alias for more categories because it has different id’s and it works to save in backend but in the last version we can’t use the same alias because the validation.
Is there a solution so we can disable the validation since we have different id’s?
In old version (life site) it works because the alias is not used, if you look in backend you will see that the alias field is not filled up.
In the last version that we see this field is mandatory and must be unique that’s why we can’t use the same alias. My developer imported contents hence we are able to have the same url format as life site but now we cannot edit one of them because you can’t save the category because of this validation problem.
I need this resolved because I need to maintain same url as my current site.
Thanks
We noticed because we have same subcategory in two different categories. In older version we can use the same alias for more categories because it has different id’s and it works to save in backend but in the last version we can’t use the same alias because the validation.
Is there a solution so we can disable the validation since we have different id’s?
In old version (life site) it works because the alias is not used, if you look in backend you will see that the alias field is not filled up.
In the last version that we see this field is mandatory and must be unique that’s why we can’t use the same alias. My developer imported contents hence we are able to have the same url format as life site but now we cannot edit one of them because you can’t save the category because of this validation problem.
I need this resolved because I need to maintain same url as my current site.
Thanks
Last edit: 10 years 1 month ago by onyc.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #248112
by nicolas
Replied by nicolas on topic Saving Category with the same or no alias
Hi,
There is no option to turn off that check. We've added it because we had people removing the ids and then having categories with the same alias, and thus when you would click on the links of one or the other category, it would go to the same category all the time.
You would have to remove the code:
from the file administrator/components/com_hikashop/classes/category.php to remove that check.
There is no option to turn off that check. We've added it because we had people removing the ids and then having categories with the same alias, and thus when you would click on the links of one or the other category, it would go to the same category all the time.
You would have to remove the code:
Code:
if(!empty($element->category_alias)) {
$query = 'SELECT category_id FROM '.hikashop_table('category').' WHERE category_alias='.$this->database->Quote($element->category_alias);
$this->database->setQuery($query);
$element_with_same_alias = $this->database->loadResult();
if(!empty($element_with_same_alias) && (empty($element->category_id) || $element_with_same_alias != $element->category_id)) {
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_( 'ELEMENT_WITH_SAME_ALIAS_ALREADY_EXISTS' ), 'error');
JRequest::setVar('fail', $element);
return false;
}
}
The following user(s) said Thank You: onyc
Please Log in or Create an account to join the conversation.
10 years 1 month ago #248157
by onyc
Replied by onyc on topic Saving Category with the same or no alias
Thanks a lot, worked!!
Please Log in or Create an account to join the conversation.
Time to create page: 0.167 seconds