- Posts: 61
- Thank you received: 1
Double aliasses
10 years 5 months ago #235428
by Digiwacht
Double aliasses was created by Digiwacht
-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.5.1
I noticed that products can have the same name and (automatic) aliasses. The link to the products always refer to the first product with that alias. Is it possible to implement a warning when an alias already excist?
-- Joomla version -- : 3.5.1
I noticed that products can have the same name and (automatic) aliasses. The link to the products always refer to the first product with that alias. Is it possible to implement a warning when an alias already excist?
Please Log in or Create an account to join the conversation.
10 years 5 months ago #235449
by nicolas
Replied by nicolas on topic Double aliasses
Hi,
Add the code:
after the code:
in the file administrator/components/com_hikashop/classes/product.php and that will do it.
Add the code:
Code:
if(!empty($product->product_alias)){
$query = 'SELECT product_id FROM '.hikashop_table('product').' WHERE product_alias='.$this->db->Quote($product->product_alias);
$this->db->setQuery($query);
$product_with_same_alias = $this->db->loadResult();
if($product_with_same_alias && (empty($product->product_id) || $product_with_same_alias!=$product->product_id)){
$app->enqueueMessage(JText::_( 'ELEMENT_WITH_SAME_ALIAS_ALREADY_EXISTS' ), 'error');
JRequest::setVar( 'fail', $product );
return false;
}
}
Code:
if($config->get('alias_auto_fill', 1) && empty($product->product_alias) && !empty($product->product_name)) {
$this->addAlias($product);
// add a letter at the beginning of the alias to avoid issues when the alias of a product starts with a number
if($config->get('sef_remove_id', 0) && (int)$product->alias > 0)
$product->alias = $config->get('alias_prefix', 'p') . $product->alias;
$product->product_alias = $product->alias;
unset($product->alias);
}
The following user(s) said Thank You: trevsmiff
Please Log in or Create an account to join the conversation.
Time to create page: 0.154 seconds