Reference Parent Product

  • Posts: 3
  • Thank you received: 0
13 years 5 months ago #21223

Hey guys,
Quick question, I have modified the products->view file to enable a CSS based gallery for my products. However when a product ahs more than one variant, it will show the images in the variant's image list rather than the parents product. How can i call the main product's image when a variant is present? I'm currently using thise code:

      
          foreach($this->element->images as $image){
  echo '<img src='.$this->lement->uploadFolder_url.$image->file_path.'" alt="'.$image->file_name.'" />';
          }

This works great when there are no variants but shows the variant's images rather than the primary product's images if a variant exists.

Last edit: 13 years 5 months ago by Zeon.

Please Log in or Create an account to join the conversation.

  • Posts: 83050
  • Thank you received: 13410
  • MODERATOR
13 years 5 months ago #21238

If you don't want to display the variant images, you can just delete the variants images display block of code in that view (the whole if(!empty($variant->images)){ block).

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
13 years 5 months ago #21247

nicolas wrote:

If you don't want to display the variant images, you can just delete the variants images display block of code in that view (the whole if(!empty($variant->images)){ block).


Hi Thanks for the reply. Oh I still want the variant images - what I really want is to be able to show one image for each variant next to the price and have 4-5 photos from the parent in a type of CSS based slideshow.

E.g. on here I have used CSS animations to make a slideshow:
sway.net.nz/new/index.php/products/tio-p.../6-tortillas-12-pack

But to show you the problem, this product has variants and thus when you call this->element-> images it overrules the 5 photos from the parent product:
sway.net.nz/new/index.php/products/tio-p...w/1-chocolate-azteca

Please Log in or Create an account to join the conversation.

  • Posts: 83050
  • Thank you received: 13410
  • MODERATOR
13 years 5 months ago #21257

Ok, I see.

The main product images should be in $this->element->main->images

The code $this->lement->uploadFolder_url is not correct and it should be $this->image->uploadFolder_url

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum