Saturday, 15 June 2013

prestashop show out of stock in attribute dropdown -



prestashop show out of stock in attribute dropdown -

im facing problem wich can't prepare maybe can help me out.

im showing dropdown sizes. want show in dropdown when product out of stock (out of stock) next size.

i have found sniped wich shows wich products out of stock:

{foreach from=$combinations key=idcombination item=combination} {if $combination.quantity == 0} {assign var=attributes value=','|explode:$combination.list} {foreach from=$groups key=id_attribute_group item=group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {foreach from=$attributes item=attribute name=attribute} {if $id_attribute == $attribute|substr:1:-1} {$group_attribute} - {* if !$smarty.foreach.attribute.last}, {/if *} {/if} {/foreach} {/foreach} {/foreach} {/if} {/foreach}

{/strip}{/if}

it works rather want show in dropdown. how can this?

update - code generates dropdown

<div id="attributes"> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <fieldset class="attribute_fieldset"> <label class="attribute_label" for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'utf-8'} :</label> {assign var="groupname" value="group_$id_attribute_group"} <div class="attribute_list"> ------ select ---------------------- {if ($group.group_type == 'select')} <select name="{$groupname}" id="group_{$id_attribute_group|intval}" class="attribute_selectt" onchange="findcombination();getproductattribute();{if $colors|@count > 0}$('#wrapresetimages').show('slow');{/if};"> {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> ------------ select endd ---------------- {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} !important;" title="{$colors.$id_attribute.name}" onclick="colorpickerclick(this);getproductattribute();{if $colors|@count > 0}$('#wrapresetimages').show('slow');{/if}"> {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" /><br> {/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')} {foreach from=$group.attributes key=id_attribute item=group_attribute} <input type="radio" class="attribute_radio" name="{$groupname}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findcombination();getproductattribute();{if $colors|@count > 0}$('#wrapresetimages').show('slow');{/if}"> {$group_attribute|escape:'htmlall':'utf-8'}<br/> {/foreach} {/if} </div> </fieldset> {/if} {/foreach} </div>

heres 1 way editing/overriding controller products. tested on prestashop 1.5.2

in controller productcontroller see function assignattributesgroups handles groups/attributes available display on views.

// wash attributes list (if attributes unavailables , if allowed wash it) if (!product::isavailablewhenoutofstock($this->product->out_of_stock) && configuration::get('ps_disp_unavailable_attr') == 0) { foreach ($groups &$group) foreach ($group['attributes_quantity'] $key => &$quantity) if (!$quantity) unset($group['attributes'][$key]); foreach ($colors $key => $color) if (!$color['attributes_quantity']) unset($colors[$key]); }

you can see here, attribute removed available groups. if want remain in list override function , controller recreating function.

change

if (!$quantity) unset($group['attributes'][$key]);

to

if (!$quantity) $group['attributes'][$key] .= " sold out";

for more info on prestashop , overriding see http://doc.prestashop.com/display/ps15/overriding+default+behaviors

prestashop

No comments:

Post a Comment