Author Topic: Link to all products from manufacturer in product details.  (Read 4099 times)

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Link to all products from manufacturer in product details.
« on: December 06, 2016, 15:46:14 pm »
Hello,
I've been trying to set the link to the 'all products from this manufacturer page', but can't get it right. I'm using a logo instead of the manufacturers name.
This is what I have in default_manufacturer.php:
Code: [Select]
<?php

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

<div class="manufacturer">
    <?php
    $link 
JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' $this->product->virtuemart_manufacturer_id'');
    
$text $this->product->mf_name;

    
/* Avoid JavaScript on PDF Output */
    
if (strtolower(JRequest::getWord('output')) == "pdf") {
echo JHTML::_('link'$link$text);
    } else {
?>

        <a href="<?php echo $link ?>"><img src="<?php echo $this->baseurl ?>/images/stories/virtuemart/manufacturer/<?php echo $this->product->mf_name ?>.jpg " title="<?php echo $text?>" alt="<?php echo $text?>"></a>
    <?PHP } ?>
</div>

I've tried all sorts of thing in the JRoute-piece, especcially in the end-part, but can't get it working. It only leads to the main shop page. What piece would work here?

Joomla! 3.6.4 / VirtueMart 3.0.18 / PHP 5.6.17

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Link to all products from manufacturer in product details.
« Reply #1 on: December 07, 2016, 18:18:11 pm »
Code: [Select]
JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id, FALSE);

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #2 on: December 08, 2016, 09:57:58 am »
Thanks K&K media production, but that's not working either... It redirects to the same main shop page.

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Link to all products from manufacturer in product details.
« Reply #3 on: December 08, 2016, 10:13:22 am »
Forgot index on manufacturer ID.

Code: [Select]
JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0], FALSE);

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4243
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Link to all products from manufacturer in product details.
« Reply #4 on: December 08, 2016, 10:45:45 am »
You can remove FALSE in jroute, it's not needed and, on removing it, display proper link.

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #5 on: December 08, 2016, 11:39:23 am »
Ghost's suggestion showed me the name of the manufacturer in the link, but didn't redirect to the concerning manufacturers page. That got me thinking if the path was correct. The manufacturers are only set as manufacturers, not as categories or menu-items.
So instead, I've been trying to find the right link:

1.
In the CustomFiltersPro-module (back-end). The only thing I could find that made sense was in this menu-item:
Code: [Select]
index.php?option=com_customfilters&view=productsSo comparing this with what I had, I came to this:
Code: [Select]
    $link = JRoute::_('index.php?option=com_customfilters&view=category&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0]);
This leads to the right page, with all the products of the manufacturer (the page is just not styled correctly, but that's a minor thing).

Only thing is: is this a correct url? Can it be cleaned up so it's a nicer url, and can it show the manufacturers name instead of the id?
For instance, when clicking 'Triumph', the link is:
Code: [Select]
http://websiteurl.com/index.php/component/customfilters/?view=category&virtuemart_manufacturer_id=1
2.
Directly through the customfilters-module in the front-end.
The link to the same manufacturer 'Triumph' for instance is:
Code: [Select]
http://websiteurl.com/index.php/zoeken-in-webshop/no-category/triumph
What would be the best way and how to retrieve the most clean, right url?

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Link to all products from manufacturer in product details.
« Reply #6 on: December 08, 2016, 12:12:35 pm »
Quote
Ghost's suggestion showed me the name of the manufacturer in the link, but didn't redirect to the concerning manufacturers page.
Where does it lead to?

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #7 on: December 08, 2016, 12:30:13 pm »
@Ghost:

The url shows:
Code: [Select]
http://websiteurl.com/index.php/component/virtuemart/manufacturer/triumph?Itemid=135but it leads to the main shop page with all categories (all "types of motors").

And when I remove the "?itemid=135"-part, it leads to a page with the main category ("type of motor").

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4243
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Link to all products from manufacturer in product details.
« Reply #8 on: December 08, 2016, 13:48:57 pm »
If you don't get right SEF link, it's because Joomla menu item is not set.
eg http://websiteurl.com/index.php/component/virtuemart/manufacturer/triumph?Itemid=135
should be http://websiteurl.com/index.php/MYSHOPHOME/manufacturer/triumph without any Itemid=135


Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #9 on: December 08, 2016, 14:36:21 pm »
Two different threads here:

The first one is using Ghost' suggestion:
Code: [Select]
JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0], FALSE);
Unfortunate this is only showing the mf-name in the link, but not redirecting to the concerning manufacturer. Instead it leads to the main shop page with all (sub)categories:
Code: [Select]
http://websiteurl.com/index.php/component/virtuemart/manufacturer/triumph?Itemid=135

The second one is using something from the customfilters in the link.
1.
In the CustomFiltersPro-module (back-end). The only thing I could find that made sense was in this menu-item:
Code: [Select]
index.php?option=com_customfilters&view=productsSo comparing this with what I had, I came to this:
Code: [Select]
    $link = JRoute::_('index.php?option=com_customfilters&view=category&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0]);
This leads to the right page, with all the products of the manufacturer (the page is just not styled correctly, but that's a minor thing).

Only thing is: is this a correct url? Can it be cleaned up so it's a nicer url, and can it show the manufacturers name instead of the id?
For instance, when clicking 'Triumph', the link is:
Code: [Select]
http://websiteurl.com/index.php/component/customfilters/?view=category&virtuemart_manufacturer_id=1
2.
Directly through the customfilters-module in the front-end.
The link to the same manufacturer 'Triumph' for instance is:
Code: [Select]
http://websiteurl.com/index.php/zoeken-in-webshop/no-category/triumph
What would be the best way and how to retrieve the most clean, right url?

That #1 does lead to the right manufacturer and his products, but doesn't show his name in the ugly url. That's the url I would want to clean up, if possible. (Or else use something like in #2, but with the right code.)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4243
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Link to all products from manufacturer in product details.
« Reply #10 on: December 08, 2016, 16:43:14 pm »
Add a Joomla menu link to categoy view and don't set any categories and manufacturer, then the links are right !
In old releases, you had a warning "please add a menu link to shop root" or similar, but now this view is obselete and if the link is not set, then you have this behavior without any warning.
So please try my suggestion and check if it solve your problem.

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #11 on: December 10, 2016, 17:40:02 pm »
Ok, after hours of trying all sorts of combinations, I'm lost, haha!

The Joomla menu link was already set (VM-category-view, without setting any category or manufacturer).

When I use:
Code: [Select]
JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0]);clicking the mf-logo gets you to this nice clean url.
But there's only the mf-name and logo, and a button 'show all products'. Unfortunate, clicking this button does not show these products, but leads to the page you're visiting already.

And when i use:
Code: [Select]
JRoute::_('index.php?option=com_customfilters&view=manufacturer&virtuemart_manufacturer_id=' . $this->product->virtuemart_manufacturer_id[0]);clicking the mf-logo gets you to this page with ugly url, where the mf-products are visible, but there's no mf-name and logo (and header at the top of this 'unofficial' page).

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Link to all products from manufacturer in product details.
« Reply #12 on: December 10, 2016, 17:50:51 pm »
The URL is correct. If no products are shown, make sure 'Show products of the selected category' is set to Yes in VM category menu item.

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Link to all products from manufacturer in product details.
« Reply #13 on: December 10, 2016, 18:17:35 pm »
With the 'com_virtuemart'-part, you mean? Nice clean url.
The 'show products' was/is set to 'yes' in VM-category menu item. Cache is cleaned, but no products are showing beneath the mf-name and logo.

And when using the customfilters-search (front-end), the url to the (in this example) Triumph-products would be this other route.