dousou3027 2014-01-24 13:51
浏览 84
已采纳

在表Prestashop中显示产品属性

Working with prestashop.

I have set up attributes for a product I need to display these in a table format like this http://www.solopress.com/leaflet-printing/bond-leaflet.html

So across the top it has the Paper Size and each row is the QTY of paper.

In my back-end I have the Attribute QTY for 250/500 etc etc and Size A4/A5/A6 etc

Is there any way I can pull the attributes from the drop down and list them as a table with the price being a Add to Cart button?

Any helpful bits of code or input would be great.

Many thanks!

  • 写回答

1条回答 默认 最新

  • dongshengli6384 2014-01-25 17:45
    关注

    This is definately not an answer but should give you a heads up on the problem itself.

    Your text was not that clear but I'll assume you mean't that you created new attribute values and assigned them under combinations tag.

    You have to create a specific table structure ( like you need ) in the product.tpl file and display the specific attrbitues by a smarty forach loop.

    By default there are three group types for attributes: select, color, radio. You can add new attributes but without alterations in the database itself ( dont know if you are able to add them via admin panel ) the group types will remain the same.

    Here is a code from product.tpl file that might help you

                        {foreach from=$groups key=id_attribute_group item=group}
                    {if $group.attributes|@count}
                        <fieldset class="attribute_fieldset span5">
                            <div id="attribute_label_container">
                            <label class="attribute_label" for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :&nbsp;</label>
                            </div>
                            {assign var="groupName" value="group_$id_attribute_group"}
                            <div class="attribute_list">
                            {if ($group.group_type == 'select')}
                                <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" onchange="findCombination();getProductAttribute();">
                                    {foreach from=$group.attributes key=id_attribute item=group_attribute}
                                        <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
                                    {/foreach}
                                </select>
                            {elseif ($group.group_type == 'color')}
                                <ul id="color_to_pick_list" class="clearfix">
                                    {assign var="default_colorpicker" value=""}
                                    {foreach from=$group.attributes key=id_attribute item=group_attribute}
                                    <li{if $group.default == $id_attribute} class="selected"{/if}>
                                        <a id="color_{$id_attribute|intval}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value};" title="{$colors.$id_attribute.name}" onclick="colorPickerClick(this);getProductAttribute();">
                                            {if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}
                                                <img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$colors.$id_attribute.name}" width="20" height="20" />
                                            {/if}
                                        </a>
                                    </li>
                                    {if ($group.default == $id_attribute)}
                                        {$default_colorpicker = $id_attribute}
                                    {/if}
                                    {/foreach}
                                </ul>
    
                                <input type="hidden" class="color_pick_hidden" name="{$groupName}" value="{$default_colorpicker}" />
                            {elseif ($group.group_type == 'radio')}
                                <ul>
                                    {foreach from=$group.attributes key=id_attribute item=group_attribute}
                                        <li>
                                            <input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();" />
                                            <span>{$group_attribute|escape:'htmlall':'UTF-8'}</span>
                                        </li>
                                    {/foreach}
                                </ul>
                            {/if}
                            </div>
                        </fieldset>
                    {/if}
                {/foreach}
    

    That will display the results in a list as you can see. To make it display in a table structure just edit the correct group_type IF content.

    I hope that it helps you a bit.

    BR's

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?