News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Show Manufacturers information on "productdetails page"

Started by tobisagt, January 04, 2012, 00:44:16 AM

Previous topic - Next topic

Snake 60

#45
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

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.

Quote from: JamesSVk on February 03, 2013, 18:30:59 PM
I got solution, try this directly on your view site (/productdetails/tmpl/default.php or in template /html/com_virtuemart/productdetails/default.php):

<?
   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

I used the above solution and in my template/html/com_virtuemart/productdetails/default.php I replaced this code:
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>


with this:
<?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

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

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

Check for substr("$manufacturer->images[0]->file_url, -1) ==='/')

        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

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

Typo corrected :

        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

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

<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:
$manlink = JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id='.$manufacturer->virtuemart_manufacturer_id, FALSE);