Brands link in Product page to Canonical

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #231742

-- HikaShop version -- : 2.6.1

Hello,

I was wondering if it was possible to change the link pointing to a brand on the product listing page to the canonical?

I would like the product listing for the brand to have the same display as if it had been pointed at from the menu.

Many thanks,
Hal

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231745

Hi,

There is no brand link on the products listing pages. It's only on the product pages. And on the product pages, the brand link already uses the canonical URL of the brand if provided.
The link is done with that code:

echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';
I'm thinking that you customized your views with an old code where the brand link is generated with hikashop_completeLink instead of hikashop_contentLink and thus it doesn't take into account the canonical URL.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #231847

Hi Nicolas,

Could you please let me know which view this code should be in?

Thanks,
Hal

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #231873

False alarm, still can't find it :(

Last edit: 9 years 6 months ago by Holmes-Pierce.

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231896

It's in the file "show_block_dimensions".

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #231951

I didn't check that one as it's not been customised, it's version 2.6.1.

Any other ideas? Canonical is definitely set.

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #231958

Hi,

If you hadd such line:
<?php exit; ?>
At the top of that file does that change the display ?
If not, it means that this whole file is not called by the show_default view file and that the show_default view file has been customized to display itself the link to the brand page.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232042

No, it breaks the product page. The file is definitely in use.

My brand URL's are set up as direct URL's. It shortens the URL and skips the parent category.

For example, Ruby Shoo is just /rubyshoo instead of /womensbrands/rubyshoo.

Could this be the problem?

This is the code at the bottom of this view:

$categoryClass->addAlias($manufacturer);
echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #232051

Hi,

I don't see how that's possible that the canonical URL of the brand wouldn't be used if you have set a canonical URL in the brand, that you're using this code, and that you have the "force canonical URLs on listings" setting activated in the HikaShop configuration.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232095

Hi,

I haven't got "force canonical URLs on listings' activated. I don't want this activated either, as I want the product pages to be accessed using different URL's. I have my reasons.

The issue I have with the brands URL is that the layout on the page is all wrong, because there isn't a menu assigned to the URL that's been given. It's prefixing all the brand URLs with /womens. This URL is used nowhere else, so I don't understand why it's being used here.

Can the code be adjusted to always use the correct canonical URL?

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #232098

Hi,

Sure, change the code:
$categoryClass->addAlias($manufacturer);
echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_contentLink('category&task=listing&cid='.$manufacturer->category_id.'&name='.$manufacturer->alias.'&Itemid='.$Itemid,$manufacturer).'">'.$manufacturer->category_name.'</a>';
to:
echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_completeLink(hikashop_cleanURL($manufacturer->category_canonical)).'">'.$manufacturer->category_name.'</a>';

And that will force the canonical URL regardless of the "force canonical URLs on listings" setting. But I'm expecting that
it won't change anything. The code is already displaying the canonical URL if that option is activated.

The problem is likely elsewhere and there is some other view which displays the brand URL and that other view has some custom code which is wrong and doesn't take into account the canonical URL at all.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232185

Hello,

That resulted in a 404 result (/anybrand/https-/www.elevateyoursole.co.uk/anybrand).

Strangely, when I replaced the code back to normal it has changed the URL to brand/... Previously it was /womens/...

Many thanks,
Hal

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #232230

Hi,

Such 404 URL would indicate that the canonical URL in the product is wrong.
Remember that it should be a relative URL and not the full URL.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232231

Hello,

All canonical URL's are set up like the screenshot. Is this correct?

Many thanks,
Hal

Attachments:

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #232234

Hi,

Yes.

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232255

So, what is the solution then?

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #232257

Try like that then:
echo JText::_('MANUFACTURER').': '.'<a href="'.hikashop_cleanURL($manufacturer->category_canonical).'">'.$manufacturer->category_name.'</a>';

The following user(s) said Thank You: Holmes-Pierce

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

  • Posts: 265
  • Thank you received: 1
9 years 6 months ago #232277

Thank you :), that has worked perfectly!

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

Time to create page: 0.080 seconds
Powered by Kunena Forum