Saving Category with the same or no alias

  • Posts: 101
  • Thank you received: 0
9 years 1 day ago #248107

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

Last edit: 9 years 12 hours ago by onyc.

Please Log in or Create an account to join the conversation.

  • Posts: 84233
  • Thank you received: 13675
  • MODERATOR
9 years 1 day ago #248112

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:

		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;
			}
		}
from the file administrator/components/com_hikashop/classes/category.php to remove that check.

The following user(s) said Thank You: onyc

Please Log in or Create an account to join the conversation.

  • Posts: 101
  • Thank you received: 0
9 years 12 hours ago #248157

Thanks a lot, worked!!

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum