How to find duplicate Alias

  • Posts: 44
  • Thank you received: 2
5 years 4 months ago #300915

-- url of the page with the problem -- : www.koffiematters.nl
-- HikaShop version -- : 4.0.0
-- Joomla version -- : 3.8.12
-- PHP version -- : 7.1

Hi folks,

We're building up a Google Shopping feed and need Brand to be part of it. Sometimes I got hit with an error saying that an alias with the same name already exist. Of course I could change the alias of the brand, but I prefer to use the base-alias for the brands. I'd like to find the "thing" that uses the same alias somehow somewhere. What's the best way to find the duplicate alias- so I can change that instead of the brand alias?

I find it quite strange that the alias is already in use, because in my opinion everything should be separated (i.e. categories, products, brands etc. should have their own aliases) - there are no brands aliases that interfere with eachother ...

I hope anyone has an idea :) Thank you very much in advance

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

  • Posts: 4519
  • Thank you received: 611
  • MODERATOR
5 years 4 months ago #300926

Hello,

For me, the most simple way is to have a look in your DataBase in order to see all your brand alias and better get what's going on.
Now, I don't advice you to modify your Sql DataBase because this can leads to many issue, for now just have a look, and if something seems strange for you, inform us to advice a little more to eventually help you.

In order to quickly have the short list of your brand, you can use this Sql request :
"SELECT * FROM `YOUR_SQL_REF_hikashop_category` WHERE `category_type` = 'manufacturer'"

Hope this will help you to move forward.
Regards

Last edit: 5 years 4 months ago by Philip.

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

  • Posts: 44
  • Thank you received: 2
5 years 4 months ago #300974

That's not what I'm looking for....
Because the alias doesn't exist in that table. We just started using the Brand field / table ...
That's the strangest thing and that's why I mentioned that I find it very odd that an alias is used multiple times somewhere.
Maybe it would help if you actually read a post in detail before giving an overall solution that doesn't cover the problem Philippe :-D

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

  • Posts: 26004
  • Thank you received: 4004
  • MODERATOR
5 years 4 months ago #300985

Hello,

Brands and categories are stored in the same table in HikaShop ; they are handled by the same class (same code).
Within the function which check the alias, the algorithm do not use the category type (which allow to see the difference between a product category, a brand category and other category types) to filter its search.
So if you create a brand with the same alias than an existing product category ; you will have that message and the save will be interrupt.

Thus, in the HikaShop category class (administrator/components/com_hikashop/classes/category.php) you can replace the line

$query = 'SELECT category_id FROM '.hikashop_table('category').' WHERE category_alias='.$this->database->Quote($element->category_alias);
By
$query = 'SELECT category_id FROM '.hikashop_table('category').' WHERE category_alias='.$this->database->Quote($element->category_alias);
if(!empty($element->category_type))
	$query .= ' AND category_type = '.$this->database->Quote($element->category_type);
In order to take the category type into consideration for the duplicate alias check.
Another improvement could be to display the ID of the category which has the same alias than the one you're currently saving. It's a bit technical but I think that it could be useful in some cases.

Please let us know about the patch, so we can validate it for an integration in the next release.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.061 seconds
Powered by Kunena Forum