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

slammy

  • Jr. Member
  • **
  • Posts: 169
  • vm supporter member
  • VirtueMart Version: vm 3.0.x and jml 3.4.5
Re: Show Manufacturers information on "productdetails page"
« Reply #30 on: May 10, 2012, 14:25:17 pm »
Tks Banquet  ;D

i use this code
<img src="<?php echo $this->baseurl ?>/images/stories/virtuemart/manufacturer/<?php echo $this->product->mf_name ?>.jpg ">
because my logos have the name of the brand..

but maybe is why i now have this problem: In some Manufacturer brands in image i have only the name like "Varta".jpg and the Brand name is the same .. but for others i have the sonyericsson.jpg but the name is sony ericsson .. and the images misses because we calls the sony%20ericsson.jpg

so.... the solution will be to change all Brand Manufacturer names in VM Backend ... and all images in folder and remove the text name and put numbers ?

use str_replace
For Example: If you have a manufacturer name like sony ericsson with a blank inside and the picture is named sonyericsson.jpg do the following to replace a blank or any other character you want:

$my_needed_imagename=str_replace(' ','', $this->product->mf_name); // first is the character you are searching for, second is the replacement, third the subject_string)

then $my_needed_imagename is sonyericsson.jpg
regards slam

Doomas

  • Beginner
  • *
  • Posts: 11
Re: Show Manufacturers information on "productdetails page"
« Reply #31 on: October 09, 2012, 02:41:21 am »
Here is my solution to display the manufacturer image. In Virtuemart 2.0.12

Replace the following code (arround line 748) in the file /administrator/components/com_virtuemart/models/product.php

Code: [Select]
if (!empty($product->virtuemart_manufacturer_id)) {
$mfTable = $this->getTable ('manufacturers');
$mfTable->load ((int)$product->virtuemart_manufacturer_id);
$product = (object)array_merge ((array)$mfTable, (array)$product);
}

with

Code: [Select]
if (!empty($product->virtuemart_manufacturer_id)) {
$mfTable = $this->getTable ('manufacturers');
$mfTable->load ((int)$product->virtuemart_manufacturer_id);
$xrefTable = $this->getTable('manufacturer_medias');
$mfImages = $xrefTable->load($product->virtuemart_manufacturer_id);
if(!empty($mfImages)) {$mfTable->mf_image_id = $mfImages[0];
$mediaModel = VmModel::getModel('Media');
$product->mf_images = $mediaModel->createMediaByIds($mfImages[0],'','image');
}
$product = (object)array_merge ((array)$mfTable, (array)$product);
}

With this change you can use following variables in your template overrides:

Code: [Select]
$this->product->mf_images[0]->file_url //url to the manufacturere image
$this->product->mf_images[0]->file_url_thumb //url to the manufacturer image thumb


mikidg1984

  • Beginner
  • *
  • Posts: 1
Re: Show Manufacturers information on "productdetails page"
« Reply #32 on: December 14, 2012, 17:04:25 pm »
My solution....

Put this code
Code: [Select]
        JRequest::setVar('virtuemart_manufacturer_id',$product->virtuemart_manufacturer_id,'GET');
        $model = VmModel::getModel('manufacturer');
if ($product->virtuemart_manufacturer_id !=0 ) {

$manufacturer = $model->getManufacturer();
$model->addImages($manufacturer,1);

$product->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
                }

between line 147-146 in product view ----->file components/com_virtuemart/views/productdetails/view.html.php

This add the manufacturerImage  fields to the template product object  ($this->product) in the view productdetails.
So you can display the  $this->product->manufacturerImage var  in the

templates/your_template/html/com_virtuemart/productdetails/default.php
or in
templates/your_template/html/com_virtuemart/productdetails/default_manufacturer.php

I hope it will be useful....
Bye......

dorex

  • Beginner
  • *
  • Posts: 47
  • VirtueMart Version: 2.0.16
Re: Show Manufacturers information on "productdetails page"
« Reply #33 on: January 03, 2013, 20:05:18 pm »
Hi,
I've tried your solutions, but it doesn't work out for me. I even tried out the last two instructions ( from users: Doomas and mikidg1984) and it didn't work ( The last two solutions don't seem to be permanent, but overwritten at the first upgrade.).

First I tried what I understood from the discussion of Banquet and Lipes, and I've inserted the following codes (one at a time) to the product details default.php (public_html/templates/MY_TEMPLATE/html/com_virtuemart/productdetails/default.php):

1. Didn't work:   <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->mf_name ?>.jpg ">
2. Didn't work:   <?php echo <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->mf_name ?>.jpg "> ?>

All the manufacturer images are in manufacturer folder ( /public_html/images/stories/virtuemart/manufacturer/ ), all images are named with the MANUFACTURER_NAME.jpg, and none of them has spaces/blanks inside their names ... images are named exactly as the Manufacturers.

Did I do something wrong, or is there anything else to be done/written in code, in order to display the manufacturer images? If anyone managed to make it work (as Lipes did), please provide an example with this code inserted.

Also, this post is very ambiguous. Can someone explain clearly what is to be done in order to show up a manufacturer image on the "Product Details" page?

Thank you.
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Re: Show Manufacturers information on "productdetails page"
« Reply #34 on: January 03, 2013, 22:51:09 pm »
Hi,
I've tried your solutions, but it doesn't work out for me. I even tried out the last two instructions ( from users: Doomas and mikidg1984) and it didn't work ( The last two solutions don't seem to be permanent, but overwritten at the first upgrade.).

First I tried what I understood from the discussion of Banquet and Lipes, and I've inserted the following codes (one at a time) to the product details default.php (public_html/templates/MY_TEMPLATE/html/com_virtuemart/productdetails/default.php):

1. Didn't work:   <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg ">
2. Didn't work:   <?php echo <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg "> ?>

All the manufacturer images are in manufacturer folder ( /public_html/images/stories/virtuemart/manufacturer/ ), all images are named with the MANUFACTURER_NAME.jpg, and none of them has spaces/blanks inside their names ... images are named exactly as the Manufacturers.

Did I do something wrong, or is there anything else to be done/written in code, in order to display the manufacturer images? If anyone managed to make it work (as Lipes did), please provide an example with this code inserted.

Also, this post is very ambiguous. Can someone explain clearly what is to be done in order to show up a manufacturer image on the "Product Details" page?

Thank you.

this code will not work, the syntax is wrong (dont have time to re-write it)
2. Didn't work:   <?php echo <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg "> ?>


THIS CODE USES THE manufacturer ID , NOT the name

 <img src="/public_html/images/stories/virtuemart/manufacturer/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg ">

look here
http://forum.virtuemart.net/index.php?topic=95818.msg333248#msg333248


I do NOT do development work for hire.

dorex

  • Beginner
  • *
  • Posts: 47
  • VirtueMart Version: 2.0.16
Re: Show Manufacturers information on "productdetails page"
« Reply #35 on: January 03, 2013, 23:17:45 pm »
Sorry, It's late and I'm tired. I pasted the wrong code in my previous reply, now it's corrected. I edited my previous reply while you were responding.
Thank you for pointing this topic, but unfortunately I have read this post (http://forum.virtuemart.net/index.php?topic=95818.msg333248#msg333248) 5 times now ... copied and pasted code ... but nothing works.

Here it is what I tried out and didn't worked:

First tried solution:

I named all the manufacturer images like this: ManufacturerName.jpg (except one of them, all my manufacturer names are one word only, so there's no blanks/spaces or other characters in the image file names).
I went to:     /public_html/templates/MY_TEMPLATE/html/com_virtuemart/productdetails/default.php
and I inserted the following code:
Code: [Select]

 
Code: [Select]
<?php echo <img src="/images/stories/virtuemart/manufacturer/<?php echo $this->product->mf_name ?>.jpg "> ?>
right above these lines:
      <?php
      if ($this->showRating) {
          $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);

          if (empty($this->rating)) {
         ?>


Second tried solution:

I've created a folder ( /images/stories/virtuemart/custom_folder/ ) where I uploaded all the manufacturer images, each one named with the manufacturer ID (1.jpg, 2.jpg, 3.jpg, 4.jpg, etc.).
I went to:     /public_html/templates/MY_TEMPLATE/html/com_virtuemart/productdetails/default.php
and I inserted the following code:
Code: [Select]

 
Code: [Select]
<?php echo <img src="/images/stories/virtuemart/custom_folder/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg" > ?>
right above these lines:
      <?php
      if ($this->showRating) {
          $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);

          if (empty($this->rating)) {
         ?>

The result in both cases is a blank page, with no errors on it. Thank you for your help.
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Re: Show Manufacturers information on "productdetails page"
« Reply #36 on: January 03, 2013, 23:38:15 pm »
its the wrong syntax
to echo "text' it has to be  in   'quotes single'

Try this
<img src="/images/stories/virtuemart/custom_folder/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg" >
I do NOT do development work for hire.

dorex

  • Beginner
  • *
  • Posts: 47
  • VirtueMart Version: 2.0.16
Re: Show Manufacturers information on "productdetails page"
« Reply #37 on: January 04, 2013, 00:22:10 am »
its the wrong syntax
to echo "text' it has to be  in   'quotes single'

Try this
<img src="/images/stories/virtuemart/custom_folder/<?php echo $this->product->virtuemart_manufacturer_id ?>.jpg" >

Thank you, Banquet! This worked like a charm.

I will also try this solution for displaying the Manufacturer image in the CATEGORY View.  Hope it will work there, too.

Thanks again.
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

JamesSVk

  • Beginner
  • *
  • Posts: 2
Re: Show Manufacturers information on "productdetails page"
« Reply #38 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):

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

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Show Manufacturers information on "productdetails page"
« Reply #39 on: February 12, 2013, 17:03:50 pm »
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;
  ?>

+1 this works to show the manufacturer image on the product detail page.


bdimov

  • Jr. Member
  • **
  • Posts: 82
  • VirtueMart Version: 2.0.24
Re: Show Manufacturers information on "productdetails page"
« Reply #40 on: April 06, 2013, 10:12:31 am »
So any test some code for manufacturer image and work? Because I read this topic and test some codes but still not working for me...

guardiano78

  • Jr. Member
  • **
  • Posts: 199
Re: Show Manufacturers information on "productdetails page"
« Reply #41 on: May 09, 2013, 16:07:00 pm »
hi,

this is for the name:
Code: [Select]
<?php echo $product->mf_name?>this for description:
Code: [Select]
<?php echo $product->mf_desc?>
They work!!!
But for the image?????

Snake 60

  • Beginner
  • *
  • Posts: 12
    • Snake 60 BLOG
  • VirtueMart Version: 2.0.22a
Re: Show Manufacturers information on "productdetails page"
« Reply #42 on: August 18, 2013, 09:59:26 am »
My solution....

Put this code
Code: [Select]
        JRequest::setVar('virtuemart_manufacturer_id',$product->virtuemart_manufacturer_id,'GET');
        $model = VmModel::getModel('manufacturer');
if ($product->virtuemart_manufacturer_id !=0 ) {

$manufacturer = $model->getManufacturer();
$model->addImages($manufacturer,1);

$product->manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"',false);
                }

between line 147-146 in product view ----->file components/com_virtuemart/views/productdetails/view.html.php

This add the manufacturerImage  fields to the template product object  ($this->product) in the view productdetails.
So you can display the  $this->product->manufacturerImage var  in the

templates/your_template/html/com_virtuemart/productdetails/default.php
or in
templates/your_template/html/com_virtuemart/productdetails/default_manufacturer.php

I hope it will be useful....
Bye......
Like say mikidg1984 and other guys, his code work in product details page, but in version 2.0.22a you need insert it not in between line 147-146 but before 152 string
Code: [Select]
$product_model->addImages($product);
$this->assignRef('product', $product);
This code will dislay the manufacturer image
Code: [Select]
echo $this->product->manufacturerImage;+woot to mikidg1984  ;)

yosandra

  • Beginner
  • *
  • Posts: 34
Re: Show Manufacturers information on "productdetails page"
« Reply #43 on: August 18, 2013, 19:28:36 pm »
@tobsagt:

#1: Open /components/com_virtuemart/views/productdetails/tmpl/default.php

Find this code:
Code: [Select]
if(VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { ?>
Move its view section to any place (in the file) you refer to

#2: Hack to the view of manufacture, you can find all at /views/manufacturer

But in top of the answers, I think you should take a time on understanding what M-V-C of Joomla do. Then it is very very easy for you to do any custom on VM ;)

Cheers,

I have this code to display the manufacturer products, but it gets me to the same category (of the manufacturer). I wonder if is possible to display in this code all manufacturer products no matter the category?

Code: [Select]
<?php
$iManufacturer $this->product;
JRequest::setVar('virtuemart_manufacturer_id',$iManufacturer->virtuemart_manufacturer_id,'GET');
$model VmModel::getModel('manufacturer');
$manufacturerURL JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' $iManufacturer->virtuemart_manufacturer_id);
if ($iManufacturer->virtuemart_manufacturer_id !=) {
$manufacturer $model->getManufacturer();
$model->addImages($manufacturer,1);
$manufacturerImage $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image-product-page"',false);
?>

</div>
<div class="product-manufacturer-information">
<div class="pleft">
<div class="product-field-type-S">
<label class="product-fields-title" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL'?></label>

</div>
</div>
<div class="manufacturer-image pright">
<a title="<?php echo JText::_('TPL_GK_LANG_VIRTUEMART_PRODUCTS_DISPLAY_MANUFACTURER_PRODUCTS'?><?php echo $iManufacturer->mf_name?>" href="<?php echo $manufacturerURL?>"><?php echo $manufacturerImage?></a>
</div>
</div>

Plase let me know if it's possible.

Kind Regards,

yosandra

  • Beginner
  • *
  • Posts: 34
Re: Show Manufacturers information on "productdetails page"
« Reply #44 on: August 24, 2013, 11:11:02 am »
@tobsagt:

#1: Open /components/com_virtuemart/views/productdetails/tmpl/default.php

Find this code:
Code: [Select]
if(VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { ?>
Move its view section to any place (in the file) you refer to

#2: Hack to the view of manufacture, you can find all at /views/manufacturer

But in top of the answers, I think you should take a time on understanding what M-V-C of Joomla do. Then it is very very easy for you to do any custom on VM ;)

Cheers,

I have this code to display the manufacturer products, but it gets me to the same category (of the manufacturer). I wonder if is possible to display in this code all manufacturer products no matter the category?

Code: [Select]
<?php
$iManufacturer $this->product;
JRequest::setVar('virtuemart_manufacturer_id',$iManufacturer->virtuemart_manufacturer_id,'GET');
$model VmModel::getModel('manufacturer');
$manufacturerURL JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' $iManufacturer->virtuemart_manufacturer_id);
if ($iManufacturer->virtuemart_manufacturer_id !=) {
$manufacturer $model->getManufacturer();
$model->addImages($manufacturer,1);
$manufacturerImage $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image-product-page"',false);
?>

</div>
<div class="product-manufacturer-information">
<div class="pleft">
<div class="product-field-type-S">
<label class="product-fields-title" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL'?></label>

</div>
</div>
<div class="manufacturer-image pright">
<a title="<?php echo JText::_('TPL_GK_LANG_VIRTUEMART_PRODUCTS_DISPLAY_MANUFACTURER_PRODUCTS'?><?php echo $iManufacturer->mf_name?>" href="<?php echo $manufacturerURL?>"><?php echo $manufacturerImage?></a>
</div>
</div>

Plase let me know if it's possible.

Kind Regards,

Hello, any solution for this? I need to display all products by the manufacturer no matter what the category we are in.I don't know if the code is ok, but it keeps into the category ,to show manufacturer products into the category we are in. I need into the code to display all manufacturer products (all categories).

Kind Regards,