2

All my magento products have 5 different images attached to them like so:

image       label       base       small       thumbnail    

Image 1 -   view A       o           o             o 
Image 2 -   view B
Image 3 -   view C
Image 4 -   view D
Image 5 -   view E

Based on the journey that the user has taken through the site and what they select i display a particular image on the product page (for example Image 3 with the label 'view C'

In my cart i have the following code to display the product image (gets thumbnail):

    <?php echo $this->getProductThumbnail()->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(280, null); ?>

In the cart I have the label value of what should show (i.e view C) so i just need to then show that particular image instead of the default thumbnail image.

Is it possible to show the image based on the label name in the cart?

2

Create a new attribute of type image.

Then save the type you want somewhere in the quote_item

then you can show the image via:

$this->helper('catalog/image')->init($product, $viewType)
| improve this answer | |
  • Thank you Fabian. Can i just confirm as I am still learning magento: I have added a fourth image attribute - refine alongside base/small/thumbnail. So when Customer A adds her product, it gets added to basket and I set Image 3 as the refine image? But what if at the same time Customer B adds the same product to the basket but with Image 5 (view E) - would they not conflict? – odd_duck Dec 9 '14 at 14:39
  • Yes they would, because of this you need one attribute per view A,B,C... so you can save the attribute name in the quote_item and then take this attribute as base. – Fabian Blechschmidt Dec 9 '14 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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