0

与 prestashop 合作。

我已经为产品设置了属性,我需要以这样的表格格式显示这些属性http://www.solopress.com/leaflet-printing/bond-leaflet.html

所以在顶部它有纸张尺寸,每一行是纸张的数量。

在我的后端,我有 250/500 等的属性数量和尺​​寸 A4/A5/A6 等

有什么方法可以从下拉列表中拉出属性并将它们列为表格,价格是添加到购物车按钮?

任何有用的代码或输入都会很棒。

非常感谢!

4

1 回答 1

1

这绝对不是答案,但应该让您对问题本身有所了解。

您的文字不是那么清楚,但我假设您的意思不是您创建了新的属性值并在组合标签下分配了它们。

您必须在 product.tpl 文件中创建一个特定的表结构(如您需要)并通过 smarty forach 循环显示特定的属性。

默认情况下,属性有三种组类型:选择、颜色、单选。您可以添加新属性,但无需更改数据库本身(不知道您是否可以通过管理面板添加它们),组类型将保持不变。

这是来自 product.tpl 文件的代码,可能会对您有所帮助

                    {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}

如您所见,这将在列表中显示结果。要使其显示在表结构中,只需编辑正确的 group_type IF 内容。

我希望它对你有所帮助。

BR的

于 2014-01-25T17:45:24.553 回答