News:

Looking for documentation? Take a look on our wiki

Main Menu

Related products layout

Started by AbsoluteVM, May 10, 2012, 10:22:54 AM

Previous topic - Next topic

AbsoluteVM

I am trying to reference a products image in the related products template, default_relatedproducts.php

obviously $this->product->image[0]->file_url references the current products im viewings image url, but I need to grab the image of the related product.

Ideally I want to output related products in a floated div and manipulate them with a jQuery carousel.

Sadly, I can't work out where I can reference whats going on. I have this output:

<span class="product-field-display">
<a title="Related Product" href="x"><img alt="" src="http://mysite.com/components/com_virtuemart/assets/images/vmgeneral/filetype_jpg.png"> Related Product </a>      
</span>

I've got some custom paths to my images, using a php thumbnail generation script.

How can I reference the products image for related products and get access to all its variables?

AbsoluteVM

So the problem is when I want to reference the product->variables, its referencing the current product detail page i'm on, not the related product.


PRO


AbsoluteVM

I can't refer to it by using $product->product_name

I can't refer to anything in the default_relatedproducts.php :/

$field->display outputs the related product

AbsoluteVM

How am I supposed to customise <?php echo $field->display ?>

PRO


Smook

But over it is HTML (link with image) and how and where I can customize it ?
EG:
<a href="#" title="Title"><img src="/images/stories/virtuemart/product/xxx.jpg" alt="xxx"><span class="vm-img-desc">xxx</span> xxx</a>

AbsoluteVM

BanquetTables, how do you customise the output of field->display? Where is that code located, outside of the core in inside?

AbsoluteVM

This controls the fields->display

            $field->display = $this->displayType($field->custom_value,$field->field_type,$field->is_list,$field->custom_price,$row,0);

Line 556 of customfields.php.

I don't know why default_relatedproducts.php is not other templating systems. Would it not be much BETTER to have this in a template, like default.php where I can use all product variables..

Can anyone answer, how can I modify how it outputs the related product structure, the curremlt HTML is not good enough.. ?

AbsoluteVM


PRO


AbsoluteVM

So people just put up with the output as stock?


nick_iFactory

Was able to get a reference to the related product using these lines in the foreach loop and then could get data out and use it like a regular template... probably not the best way of doing things though.

$productModel = VmModel::getModel ('product');
$relative = $productModel->getProduct ($field->custom_value);
      
$imageModel = VmModel::getModel('media');
      
$images = array();
foreach($relative->virtuemart_media_id as $cur_image) {
   $imageModel->_id = $cur_image;
   $images[] = $imageModel->getFile();
}