Jump to content

How to get Combination Images in Product.tpl using Smarty?


wahcalvinkwan

Recommended Posts

Those get added to the javascript in the product.tpl file, it's this section here:

{if isset($combinationImages) && $combinationImages}
    {addJsDef combinationImages=$combinationImages}
{/if}

Depending what you're wanting to do with it, that might be all you need, could just loop through that array to find out the information

Link to comment
Share on other sites

Those get added to the javascript in the product.tpl file, it's this section here:

{if isset($combinationImages) && $combinationImages}
    {addJsDef combinationImages=$combinationImages}
{/if}

Depending what you're wanting to do with it, that might be all you need, could just loop through that array to find out the information

 

I would like to get the image related to that combination and to display it.

 

Since I am making a combination matrix. Would like to show the images with respect to each combination.

Link to comment
Share on other sites

All the data should be in there for that then, as that's precisely what that's used for normally.

 

You'll just need to loop through the $combinationImages variable and write it into your matrix in a meaningful way, couldn't say offhand how to do so as I've not done that part myself, but in the array should be a unique number for each combination, which you can then put into this to generate the image:

{$link->getImageLink($product->link_rewrite, (ID GOES HERE), 'large_default')|escape:'html':'UTF-8'}

The large default bit can be changed out for different sizes if you wanted thumbnails only

  • Like 1
Link to comment
Share on other sites

All the data should be in there for that then, as that's precisely what that's used for normally.

 

You'll just need to loop through the $combinationImages variable and write it into your matrix in a meaningful way, couldn't say offhand how to do so as I've not done that part myself, but in the array should be a unique number for each combination, which you can then put into this to generate the image:

{$link->getImageLink($product->link_rewrite, (ID GOES HERE), 'large_default')|escape:'html':'UTF-8'}

The large default bit can be changed out for different sizes if you wanted thumbnails only

 

All the data should be in there for that then, as that's precisely what that's used for normally.

 

You'll just need to loop through the $combinationImages variable and write it into your matrix in a meaningful way, couldn't say offhand how to do so as I've not done that part myself, but in the array should be a unique number for each combination, which you can then put into this to generate the image:

{$link->getImageLink($product->link_rewrite, (ID GOES HERE), 'large_default')|escape:'html':'UTF-8'}

The large default bit can be changed out for different sizes if you wanted thumbnails only

Good, I understand your way. Could you please tell me how can I loop through the array for the combination image?

 

This is my last step to complete. Thanks very much!

Link to comment
Share on other sites

Here's some of the basics, should have all the info needed, how to use it would depend on your site

{if isset($combinationImages)}
   {foreach from=$combinationImages item='combination' key='combinationId' name='f_combinationImages'}
        {foreach from=$combination item='image' name='f_combinationImage'}
          {$combinationId}
          {$smarty.foreach.f_combinationImage.index}
          {$image.id_image|intval}
        {/foreach}
   {/foreach}
{/if}
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...