Author Topic: Show Manufacturers information on "productdetails page"  (Read 28448 times)

Snake 60

  • Beginner
  • *
  • Posts: 12
    • Snake 60 BLOG
  • VirtueMart Version: 2.0.22a
Re: Show Manufacturers information on "productdetails page"
« Reply #45 on: August 25, 2013, 12:16:34 pm »
I think, need to write query to a DataBase for realize that. Is here any True PROgrammers? ;) I noob in php, but I will try to do that, becouse me need too this feature. :)

CasperH

  • Beginner
  • *
  • Posts: 13
Re: Show Manufacturers information on "productdetails page"
« Reply #46 on: August 12, 2015, 21:29:52 pm »
JamesSVk, thank you very very much for below code. It can easily be added on the detail page, requires no core changes, is upgrade proof and does exactly what it needs to do!

I'm replying to this "old" thread to also confirm this works for VM 3.0.9 and it hopefully points new people also to this solution, as it was still being asked in this thread even though a solution was provided.

I got solution, try this directly on your view site (/productdetails/tmpl/default.php or in template /html/com_virtuemart/productdetails/default.php):

Code: [Select]
<?
   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);
$this->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
                }
              echo $this->manufacturerImage;
  ?>

Geppux

  • Jr. Member
  • **
  • Posts: 161
Re: Show Manufacturers information on "productdetails page"
« Reply #47 on: December 10, 2015, 11:15:47 am »
I used the above solution and in my template/html/com_virtuemart/productdetails/default.php I replaced this code:
Code: [Select]
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>

with this:
Code: [Select]
<?php
// Manufacturer of the Product

   
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($manufacturer,1);
$this->manufacturerImage $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
                }
              echo 
$this->manufacturerImage;
?>

and now I have the logo instead of the name of the manufacturer, but the name was linked, clicking on it I was going on the manufacturer virtuemart page and now it's no more linked... what I have to change to have the logo linked to the manufacturer page as before or, better, to display all the products of the manufacturer?
Thank you.
Giuseppe

escozul

  • Beginner
  • *
  • Posts: 26
  • Skype Name: escozul
Re: Show Manufacturers information on "productdetails page"
« Reply #48 on: March 16, 2017, 17:03:36 pm »
Hello,

The above code from Geppux still works for VM 3

However it seems that the link issue is not worked out yet and also, I'd like an if clause to actually hide the image of the manufacturer if none is set. Right now, that code displays a no-image set image when a manufactrer has no logo.

Do you guys have any suggestions to that?

Thanks

escozul

  • Beginner
  • *
  • Posts: 26
  • Skype Name: escozul
Re: Show Manufacturers information on "productdetails page"
« Reply #49 on: April 20, 2017, 17:55:12 pm »
Sorry for bumping this but maybe someone who could help would see it this time? I have still not been able to figure it out without a bit of guidance

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2112
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Show Manufacturers information on "productdetails page"
« Reply #50 on: April 21, 2017, 12:17:49 pm »
Check for substr("$manufacturer->images[0]->file_url, -1) ==='/')
Code: [Select]
        if ($this->product->virtuemart_manufacturer_id !=0 ) {
$manufacturer = $model->getManufacturer();
$model->addImages($manufacturer,1);
if( substr($manufacturer->images[0]->file_url, -1) ==='/') ) {
$this->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
              echo $this->manufacturerImage;
                }
                }

escozul

  • Beginner
  • *
  • Posts: 26
  • Skype Name: escozul
Re: Show Manufacturers information on "productdetails page"
« Reply #51 on: April 21, 2017, 19:47:37 pm »
Hello,

Thanks for posting. However I couldn't get it to work. it also crashed the product details page. I would get a white page when using this code :(

Could there be a typo in the code?

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2112
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Show Manufacturers information on "productdetails page"
« Reply #52 on: April 21, 2017, 21:31:30 pm »
Typo corrected :
Code: [Select]
        if ($this->product->virtuemart_manufacturer_id !=0 ) {
$manufacturer = $model->getManufacturer();
$model->addImages($manufacturer,1);
if( substr($manufacturer->images[0]->file_url, -1) ==='/' ) {
$this->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
              echo $this->manufacturerImage;
                }
                }


escozul

  • Beginner
  • *
  • Posts: 26
  • Skype Name: escozul
Re: Show Manufacturers information on "productdetails page"
« Reply #53 on: April 25, 2017, 08:25:08 am »
Oh Great That in deed worked.. However I still fail to see where the difference is.. I suppose my eyes are failing me... I can't locate the typo but the new code works! It works like a charm actually.

I also changed it a bit to make the image link to the manufacturer page:

I will place below here the whole additional info div which includes rating, email to a friend and pdf link

Code: [Select]
<div class="product-additional-info">
    <?php
    // Rating
    echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));
                    
?>
<br><?php //Break a line
    // Manufacturer of the Product
    if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
        //echo $this->loadTemplate('manufacturer'); //I commented this out to hide the manufacturer text.
    }
                    
//Androutsos: Logo of the manufacturer
                    
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) { //I placed this here to hide the manufacturer image. Below code is not finished yet and does not display properly when there is no manufacturer image
                        
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($manufacturer,1);
                            
$manlink JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id='.$manufacturer->virtuemart_manufacturer_idFALSE);
                            if( 
substr($manufacturer->images[0]->file_url, -1) !='/' ) { //as suggested here: http://forum.virtuemart.net/index.php?topic=95818.new;topicseen#new
                                
$this->manufacturerImage $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
                                
?>
<a class="manufacturer" href="<?php echo $manlink?>"><?php echo $this->manufacturerImage?></a><?php
                            
}
                        }
                    }
                    
?>
<br><?php //Break a line
    ?>

   
    <?php if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) : ?>
    <?php
    $link 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->virtuemart_product_id;

echo $this->linkIcon($link '&format=pdf''COM_VIRTUEMART_PDF''pdf_button''pdf_icon'false);
echo $this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon',false,true,false,'class="printModal"');
$MailLink 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component';
    echo $this->linkIcon($MailLink'COM_VIRTUEMART_EMAIL''emailButton''show_emailfriend'false,true,false,'class="recommened-to-friend"');
    ?>

    <?php echo $this->edit_link?>
    <?php endif; // PDF - Print - Email Icon END ?>
        </div>
I have also added the link to the manufacturer's products there but you may change it to get redirected to the manufacturer's details page:
Code: [Select]
$manlink = JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id='.$manufacturer->virtuemart_manufacturer_id, FALSE);