Author Topic: Related products layout  (Read 4841 times)

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Related products layout
« on: May 10, 2012, 10:22:54 am »
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

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #1 on: May 10, 2012, 12:47:35 pm »
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.

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #2 on: May 10, 2012, 15:07:42 pm »

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10400
  • VirtueMart Version: 3+
Re: Related products layout
« Reply #3 on: May 10, 2012, 18:13:59 pm »
http://forum.virtuemart.net/index.php?topic=100696.0


$this->     refers to the ID thats in the url.

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #4 on: May 11, 2012, 11:25:48 am »
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

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #5 on: May 11, 2012, 15:07:57 pm »
How am I supposed to customise <?php echo $field->display ?>

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10400
  • VirtueMart Version: 3+
Re: Related products layout
« Reply #6 on: May 11, 2012, 15:16:55 pm »
field->display is the HTML

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Smook

  • Beginner
  • *
  • Posts: 2
Re: Related products layout
« Reply #7 on: May 12, 2012, 21:27:23 pm »
But over it is HTML (link with image) and how and where I can customize it ?
EG:
Code: [Select]
<a href="#" title="Title"><img src="/images/stories/virtuemart/product/xxx.jpg" alt="xxx"><span class="vm-img-desc">xxx</span> xxx</a>

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #8 on: May 14, 2012, 11:27:17 am »
BanquetTables, how do you customise the output of field->display? Where is that code located, outside of the core in inside?

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #9 on: May 14, 2012, 11:39:43 am »
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

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #10 on: May 21, 2012, 11:15:03 am »
Any ideas ?

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10400
  • VirtueMart Version: 3+
Re: Related products layout
« Reply #11 on: May 21, 2012, 11:40:27 am »
no idea
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #12 on: May 21, 2012, 13:39:49 pm »
So people just put up with the output as stock?

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Related products layout
« Reply #13 on: May 24, 2012, 11:21:15 am »
lol. :(

nick_iFactory

  • Beginner
  • *
  • Posts: 2
Re: Related products layout
« Reply #14 on: September 20, 2013, 09:09:04 am »
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();
}