Double aliasses

  • Posts: 61
  • Thank you received: 1
8 years 2 weeks ago #235428

-- 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?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 years 2 weeks ago #235449

Hi,

Add the 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;
			}
		}
after the 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);
		}
in the file administrator/components/com_hikashop/classes/product.php and that will do it.

The following user(s) said Thank You: trevsmiff

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

Time to create page: 0.060 seconds
Powered by Kunena Forum