Link Product Options to corresponding product pages

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
4 years 9 months ago #308864

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.8
-- PHP version -- : 7.2

Is there any way to link to the product pages of the product options added? The description is shown in a tooltip on hover, so it has to know where the product information is stored in the database. Surely, pulling the URL isn't an impossible task? I know where to update it, but unsure how to pull the product_url in the view "product / option.php". Some customers want to view the whole product page before deciding to add it as a product option.

Example page: www.mojooutdoors.com/spinning-wing-decoy...series-pintail-decoy

Thank you for your time!

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
4 years 9 months ago #308879

Hi,

Normally, you should configure the canonical URL of each product in its corresponding field for better SEO.
It seems that you did that on your website.
So you already have that URL available directly in $optionInfo->product_canonical so then it's easy to generate the link.
So instead of the line:
echo $optionInfo->product_name . $options;
you could have:
echo '<a href="'.$optionInfo->product_canonical.'">'.$optionInfo->product_name .'</a>'. $options;

You might have to prepend the canonical URL with the URL of the website based on what you have in the canonical URL field and how your website is configured.

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
4 years 9 months ago #308968

Unfortunately, my canonical URLs are managed with sh404sef. Because of this, the product_canonical isn't readily available within this view (not a hika param in this case). Do i have any other options besides, moving the canonical to hikashop? Only a days worth of copy/paste, so not too concerned. Just wanted to know if there was another option in general. Thanks!

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
4 years 8 months ago #309006

Hi,

Well, in that case you could use something like that instead:

global $Itemid;
$url_itemid = !empty($Itemid) ? ('&Itemid=' . $Itemid) : '';
$class = hikashop_get('class.product');
$class->addAlias($optionInfo);
$link = hikashop_contentLink('product&task=show&cid=' . (int)$optionInfo->product_id . '&name=' . $optionInfo->alias . $url_itemid, $optionInfo);
echo '<a href="'.$link.'">'.$optionInfo->product_name .'</a>'. $options;

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
4 years 8 months ago #309167

Thanks!

Is there any harm to use the canonical in sh404sef vs hikashop? What if you have both filled out? Will one override the other?

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
4 years 8 months ago #309175

Hi,

From what I understand, the canonical feature in sh404SEF allows you to insert a canonical URL tag for a specific page.
HikaShop does that on the product page if you fill in the canonical URL field of the product.
The only thing to check on is whether you get two tags on the page or not.
If the sh404SEF canonical feature is done properly, it should override the canonical URL tag of HikaShop instead of adding another one. In that case, you could have both filled out. Otherwise, I would recommend filling only one of them. Otherwise, Google will complain about it.
It's important to fill either one for the product pages. The canonical URL in HikaShop can bypass the SEF URL routing if you force it on listings. In that case, if you clear the URL alias cache of sh404SEF, you'll end up with 404 errors. So it might be safer to only fill sh404SEF canonical URLs to avoid potential issues in the future when you need to clear sh404SEF's cache.

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

  • Posts: 173
  • Thank you received: 14
  • Hikashop Business
4 years 8 months ago #309919

nicolas wrote: Hi,

From what I understand, the canonical feature in sh404SEF allows you to insert a canonical URL tag for a specific page.
HikaShop does that on the product page if you fill in the canonical URL field of the product.
The only thing to check on is whether you get two tags on the page or not.
If the sh404SEF canonical feature is done properly, it should override the canonical URL tag of HikaShop instead of adding another one. In that case, you could have both filled out. Otherwise, I would recommend filling only one of them. Otherwise, Google will complain about it.
It's important to fill either one for the product pages. The canonical URL in HikaShop can bypass the SEF URL routing if you force it on listings. In that case, if you clear the URL alias cache of sh404SEF, you'll end up with 404 errors. So it might be safer to only fill sh404SEF canonical URLs to avoid potential issues in the future when you need to clear sh404SEF's cache.

I've got the same issue but we only have the inbuilt 'search friendly URLs' turn on in Joomla's config. So the canonicals always seem to have the wrong category path in them. The result is, searches work as far as products go but a 404 error also appears ( link ). Is there a way to easily regenerate the canonicals and do I need to turn off 'search friendly URLs'?

Thanks,
Ian and Stu

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
4 years 8 months ago #309937

Hi,

The easiest to regenerate the canonical URLs is to empty them with a mass action (menu System>Mass actions, with an action "update the values" on the column "product_canonical") and then, HikaShop will fill them in automatically when needed if you have the "force canonical URLs on listings" setting of the HikaShop configuration set to "Use canonical URL and generate it if missing"

The following user(s) said Thank You: smithshop123

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

Time to create page: 0.082 seconds
Powered by Kunena Forum