Jump to content

url to product combination on product-list page lack color id # and attribute id #


TimTamTom

Recommended Posts

Hey there guys and girls,

 

I'm fighting with the product-list-colors.tpl..

 

The url on the product-list page does not link to the right product combination, the url it shows:

 

 (https://www.sunheroes.nl/)117-mr-blitz.html#/color-honing/combinatie-20728_honing_gradient

 

However it should be:

 

  (https://www.sunheroes.nl/)117-mr-blitz.html#/202-color-honing/241-combinatie-20728_honing_gradient

 

In the product-list-colors.tpl the code that creates the url is as follows:

 
{assign var='img_color_exists' value=file_exists($col_img_dir|cat:$color.id_attribute|cat:'.jpg')}
<li>
<a href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute)|escape:'html':'UTF-8'}" data-productid="{$color.id_product}" data-productattribute="{$color.id_product_attribute}" id="color_{$color.id_product_attribute|intval}" class="swap_color color_pick"{if !$img_color_exists && isset($color.color) && $color.color} style="background:{$color.color};"{/if}>
{if $img_color_exists}
<img src="{$img_col_dir}{$color.id_attribute|intval}.jpg" alt="{$color.name|escape:'html':'UTF-8'}" title="{$color.name|escape:'html':'UTF-8'}" width="20" height="20" />
{/if}
</a>
</li>

How to edit the above (or a Controller?) so it shows the color and attribute id number?

 

Help is much appreciated!!

 

Thanks,

 

Tim

Edited by TimTamTom (see edit history)
Link to comment
Share on other sites

Your code is missing a few parameters. It should be:

<a href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute, Configuration::get('PS_REWRITING_SETTINGS'), false, true)|escape:'html':'UTF-8'}" data-productid="{$color.id_product}" data-productattribute="{$color.id_product_attribute}" id="color_{$color.id_product_attribute|intval}" class="swap_color color_pick"{if !$img_color_exists && isset($color.color) && $color.color} style="background:{$color.color};"{/if}>

Note the addition of Configuration::get('PS_REWRITING_SETTINGS'), false, true to the getProductLink function call. That will set the add_anchor parameter to true, which should cause the IDs to be added.

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...