I'm using Joomla! 3.10.6 and Virtuemart 3.8.9 with PHP 7.4.27. On the product details page, I linked the manufacturer logo to the manufacturer products page, but the link Itemid is wrong...
Here is the code I implemented:
<?php
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
JRequest::setVar('virtuemart_manufacturer_id',$this->product->virtuemart_manufacturer_id,'GET');
$model = VmModel::getModel('manufacturer');
if ($this->product->virtuemart_manufacturer_id !=0 ) {
$manufacturer = $model->getManufacturer();
$model->addImages($manufacturer, 1);
$manlink = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id='.$manufacturer->virtuemart_manufacturer_id, FALSE);
if (substr($manufacturer->images[0]->file_url, -1) !='/') {
$this->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"', false);
?>
<a class="manufacturer" href = "<?php echo $manlink; ?>"><?php echo $this->manufacturerImage; ?></a>
<?php
}
}
}
?>
Like this, the link Itemid is the same as the one in the product page. So it isn't the manufacturer menu Itemid. Could you help me to create a code to auto assign the correct Itemid for the manufacturer menu? Thank you!
I just use the Itemid of the main shop menu .. the VM base menu
so
foreach($this->product->manufacturers as $manufacturers_details) {
$link = 'index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $manufacturers_details->virtuemart_manufacturer_id.'&Itemid=440';
$name = '<img src="'.$manufacturers_details->images[0]->file_url.'">';
$mans[] = JHtml::_('link', $link, $name);
}
e.g. https://www.escape-watersports.co.uk/clothing/towels-robes/towel-changing-robes/alder-coral-surf-poncho-detail
Where did you add this code?
in the prod details default_manufacturer.php
QuoteI just use the Itemid of the main shop menu .. the VM base menu
so
foreach($this->product->manufacturers as $manufacturers_details) {
$link = 'index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $manufacturers_details->virtuemart_manufacturer_id.'&Itemid=440';
$name = '<img src="'.$manufacturers_details->images[0]->file_url.'">';
$mans[] = JHtml::_('link', $link, $name);
}
e.g. https://www.escape-watersports.co.uk/clothing/towels-robes/towel-changing-robes/alder-coral-surf-poncho-detail
But I have a multilingual site, so I have 2 Itemid... :-\
I replied in another task:
- you have to ask in DB if exist menu item for shop (and exactly for every language) and then this ItemID in PHP add to link.
This is standard function in Joomla in router.php for article.
I believe in VM will be in next time too.
Quote from: vmproblem1 on March 30, 2022, 12:10:11 PM
<?php
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
Why do you have this? The default.php checks this before calling the layout.
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
I think this is the line which is really changing the Itemid, right? The other stuff seems to add just the images, right?
JRequest::setVar('virtuemart_manufacturer_id',$this->product->virtuemart_manufacturer_id,'GET');
This is a complex problem. Because it depends, if you have menu entries for your manufacturers, or not. And which behaviour we want to have. If you are in the productdetail, the itemid can be home, or the last category you was in, or the itemid of the productdetail menu link (very rare). Your manufacturer can have an entry and an itemid, or not. So first we should get clear about the different options.
Quote from: pinochico on March 31, 2022, 10:17:14 AM
I believe in VM will be in next time too.
OMG, you really write so much nonsense. Unbelievable.Virtuemart does not need different item menus for different languages.
And your answer is just wrong. You are not differing enough. The questions is not the menuitemd of the homepage, that is anyway the fallback for any.
Quote from: Milbo on March 31, 2022, 10:29:21 AM
I think this is the line which is really changing the Itemid, right? The other stuff seems to add just the images, right?
JRequest::setVar('virtuemart_manufacturer_id',$this->product->virtuemart_manufacturer_id,'GET');
Yes, it is correct.
Quote
This is a complex problem. Because it depends, if you have menu entries for your manufacturers, or not. And which behaviour we want to have. If you are in the productdetail, the itemid can be home, or the last category you was in, or the itemid of the productdetail menu link (very rare). Your manufacturer can have an entry and an itemid, or not. So first we should get clear about the different options.
Yes, I have a menu entry for each manufacturer. And modules with different links and photos for each manufacturer.... So with the wrong Itemid, modules are wrong.... I would like to define the manufacturer Itemid menu entry