Assign the correct Itemid to manufacturer products link form product details

Started by vmproblem1, March 30, 2022, 12:10:11 PM

Previous topic - Next topic

vmproblem1

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 !=) {
        
$manufacturer $model->getManufacturer();
        
$model->addImages($manufacturer1);
        
$manlink JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id='.$manufacturer->virtuemart_manufacturer_idFALSE); 
        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!

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

vmproblem1

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...  :-\

pinochico

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.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

vmproblem1

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