Minkiu Posted September 26, 2013 Share Posted September 26, 2013 Hello everyone, I'm facing a problem, which after looking (searching) Google and the Forums couldn't find a solution, I found similar problems or related but none seem to do for me. What I need to achieve is this: look the attatched image Explanation: I want to display the Quantity of stock of each of my combinations as shown in the image. So far I believe I've to add a "simple" line here (in product.tpl): <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" 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> In the <option> tag, but I don't figure out how exactly retrieve the quantity of each attribute. So anyone know how to deal with this? Or maybe it's possible with the Advanced Stock Managment without having to code? :/ Thanks in advance! Cheers. Link to comment Share on other sites More sharing options...
Minkiu Posted October 3, 2013 Author Share Posted October 3, 2013 Bump. Does anyone know how to achieve this? It can't be that difficult.. Link to comment Share on other sites More sharing options...
dhada Posted November 4, 2013 Share Posted November 4, 2013 <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" 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'} {$group.attributes_quantity[{$id_attribute|intval}]}</option>{/foreach}</select> this will display the quantity {$group.attributes_quantity[{$id_attribute|intval}]} 2 Link to comment Share on other sites More sharing options...
shiggidydog Posted September 14, 2016 Share Posted September 14, 2016 Does anyone have a solution for this in prestashop v1.6? I know that the database structure has changed. Not sure which version the original solution was for, but I'd like to have the inventory display next to the attribute name in the drop down. Does anyone have any ideas on how I can achieve this? Thanks! Link to comment Share on other sites More sharing options...
tantouser Posted March 26, 2017 Share Posted March 26, 2017 The dahda solutions worked for my in the product.tpl, I am looking for a solution for product_list.tpl, integrated with the template. I have the solution to display the array for all attributes, changing the id of the category you want $category = new Category(14,(int)Context::getContext()->language->id); $nb = (int)(Configuration::get('MOD_NBR')); $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)); foreach ($products as $key=>$row) { $combi[] =array( 'id_product' => $row['id_product'], 'id_product_attribute' => $row['id_product_attribute'], 'reference' => $row['reference'], 'link_rewrite'=>$row['link_rewrite'], 'link'=>$row['link'], 'id_image'=>$row['id_image'], 'name'=>$row['name'], 'price'=>$row['price'], 'quantity_all_versions'=>$row['quantity_all_versions'], 'datos_atr'=> $this->getProductAttributeCombinations($row['id_product'], (int)$this->context->language->id), ); } //$combinations= $this->getProductAttributeCombinations($products); // echo ('hola');print_r($products); $this->context->smarty->assign (array( 'products'=> $products, 'combinations'=> $combinations, 'combi' =>$combi, )); adding this function public function getProductAttributeCombinations($product) { $combinations = array(); $product = new Product ($product, $this->context->language->id); $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); return $combinations; } This return the array of products whit their attributes inside,in another array, in with I have the data of quantity, but, I dont know if exist a faster solution integrated with product list.tpl that display the quantities of the attributes for this product Link to comment Share on other sites More sharing options...
wesleifelix Posted May 10, 2017 Share Posted May 10, 2017 (edited) <select class="form-control attribute_select no-print" name="{$groupName}" id="group_{$id_attribute_group|intval}"> {foreach from=$group.attributes key=id_attribute item=group_attribute} {if ($group.attributes_quantity[{$id_attribute|intval}] <= 0)} {$disabledvar = "disabled"} {$esgotado = "Esgotado"} {else} {$disabledvar = ""} {$esgotado = ""} {/if} <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:'html':'UTF-8'}" {$disabledvar}>{$group_attribute|escape:'html':'UTF-8'} {$esgotado}</option> {/foreach} </select> Edited May 10, 2017 by wesleifelix (see edit history) 1 1 Link to comment Share on other sites More sharing options...
alano3city Posted December 31, 2019 Share Posted December 31, 2019 How could I get combination image url instead of quantity in this dropdown? Link to comment Share on other sites More sharing options...
Kaper Posted April 22, 2020 Share Posted April 22, 2020 Hey guys, any solution for 1.6 ? I tried all codes here, and no one working as should ... Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now