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

slammy

Quote from: lipes on April 04, 2012, 20:57:08 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

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


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


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:


$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

My solution....

Put this code

        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

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

Quote from: dorex 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->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



dorex

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]

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

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

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

dorex

Quote from: PRO 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" >

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

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

AbsoluteVM

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


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


bdimov

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

hi,

this is for the name:
<?php echo $product->mf_name?>
this for description:
<?php echo $product->mf_desc?>

They work!!!
But for the image?????

Snake 60

Quote from: mikidg1984 on December 14, 2012, 17:04:25 PM
My solution....

Put this code

        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
$product_model->addImages($product);
$this->assignRef('product', $product);

This code will dislay the manufacturer image
echo $this->product->manufacturerImage;
+woot to mikidg1984  ;)

yosandra

Quote from: JtouchMobile.com on January 05, 2012, 04:07:01 AM
@tobsagt:

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

Find this code:
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?

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

Quote from: yosandra on August 18, 2013, 19:28:36 PM
Quote from: JtouchMobile.com on January 05, 2012, 04:07:01 AM
@tobsagt:

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

Find this code:
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?

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