Alias automatic filling is not working

  • Posts: 23
  • Thank you received: 0
5 years 6 months ago #193434

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

Hi.
Help me please. What I do wrong?
After import of products field alias - blank.
If Alias automatic filling - yes field must be filled from the product title?


I Remove products and categories id in URLs and Force canonical URLs on listings - Use canonical URL and generate it if missing

Products are available in the list of products,. they have canonical URLs. But I get a "product not found" on the product card. If I to save product in the backend - alias is created. and the product is available in product card. This is for a single product, but they are many...

Attachments:

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

  • Posts: 70518
  • Thank you received: 10587
  • MODERATOR
5 years 6 months ago #193573

Hi,

The auto filling of aliases is done at the saving of the product. So that's normal that they are not filled until you save the products.
One possibility is to have a product_alias column in your CSV and import the CSV with the alias prefilled for all your products.

It's normal that you get the error with you turn on the remove ids from URLs and the Force canonical URLs.
Your canonical URLs don't have the id in them, so the only thing the system can rely on when you click on the link is the text of the product in the URL. If you don't have the aliases filled, the text in the URL will come from the product name and if that text is different from the name, it won't be able to find the product as it doesn't have any valid identification mean.

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

  • Posts: 23
  • Thank you received: 0
5 years 6 months ago #193620

Thanks for the answer.
The problem is that in my CSV file no field product_alias. But I added option to auto filling alias when importing CSV.
Added code to the function _insertOneTypeOfProducts (administrator/components/com_hikashop/helpers/import.php) on line 1792

						$config =& hikashop_config();
						if($config->get('alias_auto_fill',1) && $field=='product_alias' && empty($product->product_alias)){
		                   $product->product_alias = strip_tags(preg_replace('#<span class="hikashop_product_variant_subname">.*</span>#isU','',$product->product_name));
		                   }
			               if($config->get('sef_remove_id',0)){
				              $int_at_the_beginning = (int)$product->product_alias;
				                if($int_at_the_beginning){
					              $product->product_alias = $config->get('alias_prefix','p').$product->product_alias;
				                }
			               }
						   $config = JFactory::getConfig();
		                   if(!$config->get('unicodeslugs')){
			                  $lang = JFactory::getLanguage();
			                  $product->product_alias = $lang->transliterate($product->product_alias);
		                   }
		                   $app = JFactory::getApplication();
		                   if(method_exists($app,'stringURLSafe')){
			                  $product->product_alias = $app->stringURLSafe($product->product_alias);
		                   }else{
			                  $product->product_alias = JFilterOutput::stringURLSafe($product->product_alias);
						  }

Automatic creates an alias if:
  • field alias - blank
  • Alias automatic filling - yes
  • CSV file haven't a product_alias column


This code works. But I do not know Is this right...

Last edit: 5 years 6 months ago by ifenix.

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

  • Posts: 70518
  • Thank you received: 10587
  • MODERATOR
5 years 6 months ago #193645

Hi,

That's indeed a possibility yes. The code looks ok.

The following user(s) said Thank You: ifenix

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

Time to create page: 0.069 seconds
Powered by Kunena Forum