1

I have a slideshow at the top of my product description.

This slideshow uses photos from the images list of the product. I still have a photo gallery. To do the differentiation, the previous programmer uses the following rule : if a photo is excluded from gallery, then it is in slideshow.

This solution was good till now, as now, I want as well to have a photo for my category listing (i.e. small photo) and that photo should be neither in the slideshow nor in the gallery.

For the images, Is there a way to add a column (in backend), similar to the "Exclude" one, so that I can have a column "Slideshow" and restore the Exclude functionality to its original.

While I'm at it, how should I do then to fetch this so defined Slideshow list?

4
  • Did you manage to get the issue resolved? Dec 18, 2014 at 12:36
  • as I answered below, no, but I have a potential idea where I need help, at least to get some pointers. basically, the idea would be to override the function that gets the image for the gallery (i.e. $this->getGalleryImages()), with an improved function $this->getGalleryImages(0,100), the 2 numeric parameters being the position from and to I extract.
    – Memes
    Feb 26, 2015 at 8:49
  • that could then give for my Gallery : $this->getGalleryImages(0,100) and for my slideshow $this->getGalleryImages(101,200). I then re-abilitate my exclude function and can now create sub-lists of image, just putting the right code in the template and the right position in backend
    – Memes
    Feb 26, 2015 at 8:56
  • I just need to find where is that damn function
    – Memes
    Feb 26, 2015 at 8:56

2 Answers 2

1

You could add a new image attribute slideshow_image to the products attribute set. This post on pixafy explains how. This would enable you to retrieve all the images for the product collection slidehow by search for the images in the slideshow_image attribute.

1
  • Thanks for the answer, so, that helps me for another topic, but not for this one. The issue here is that with this solution, I can get only 1 image for my slideshow, I need more than 1... in other words, your solution adds a column of radio buttons while I need a column of tickboxes.
    – Memes
    Feb 26, 2015 at 8:46
0

OK, I got 2 working solutions

1. From the template

Display the image if the condition on the position is filled-in

  <?php foreach ($this->getGalleryImages() as $i => $_image): ?>
        <?php if($_image->getPosition()<100){ //Display in Gallery only those with position below 100 ?>
        //Display the image here
    <?php } ?>
<?php endforeach; ?>

2. overwrite the extracting function

public function getGalleryImages($min=0,$max=0)
{
    if ($this->_isGalleryDisabled) {
        return array();
    }

    $product = $this->getProduct();
    if(!$product->hasData('media_gallery_images') && is_array($product->getMediaGallery('images'))) {
        $images = new Varien_Data_Collection();
        foreach ($product->getMediaGallery('images') as $image) {
            if ($image['disabled']) {
                continue;
            }
            if($min!==$max AND ( $image['position']<$min OR $image['position']>$max )){
                continue;
            }
            $image['url'] = $product->getMediaConfig()->getMediaUrl($image['file']);
            $image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
            $image['path'] = $product->getMediaConfig()->getMediaPath($image['file']);
            $images->addItem(new Varien_Object($image));
        }
        return $images;
    }
}

Note that I added a fallback for all previous call to this function, the min and max will both be at 0 disabling the extra thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.