keat Posted March 10, 2016 Share Posted March 10, 2016 any way to do this please ?. I guess I need to somehow ling product_code with the warning, but i don'y know how to do that. I'm close, but no cigar. {if isset($STOCK)} <div id="stock_warnings" class="tab_content"> <h3>{$LANG.dashboard.title_stock_warnings}</h3> <table width="70%"> <thead> <tr> <th width="20" align="left">{$LANG.catalogue.product_code}</th> <th>{$LANG.catalogue.product_name}</th> <th width="65" nowrap="nowrap">{$LANG.dashboard.stock_level}</th> <th width="10"> </th> </tr> </thead> <tbody> {foreach from=$STOCK item=warn} <tr> <td width="20" align="left"> {$product.product_code}</td> <td><a href="?_g=products&action=edit&product_id={$warn.product_id}{if $warn.M_use_stock==1}#Options{/if}">{$warn.name}</a></td> <td align="center" width="65" nowrap="nowrap">{if $warn.M_use_stock==1}{$warn.M_stock_level}{else}{$warn.I_stock_level}{/if}{if $warn.cached_name} - {$warn.cached_name} {/if} </td> <td width="30"> <a href="?_g=products&action=edit&product_id={$warn.product_id}{if $warn.M_use_stock==1}#Options{/if}" class="edit"><i class="fa fa-pencil-square-o" title="{$LANG.common.edit}"></i></a><a href="?_g=products&delete={$warn.product_id}&dashboard=1" class="delete" title="{$LANG.notification.confirm_delete}"><i class="fa fa-trash" title="{$LANG.common.delete}"></i></a> </td> </tr> {/foreach} </tbody> </table> <div>{$STOCK_PAGINATION}</div> </div> {/if} {if isset($PLUGIN_TABS)} {foreach from=$PLUGIN_TABS item=tab} {$tab} {/foreach} {/if} Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 10, 2016 Share Posted March 10, 2016 Please look at these statements: {foreach from=$STOCK item=warn} <tr> <td width="20" align="left"> {$product.product_code}</td> The {foreach} is a loop that iterates across an array named $STOCK that holds a collection of items that have been determined are at a stock level that needs your attention. At each element of the array, a temporary variable named $warn holds the data of that one particular array element. So, to reference the product inside the loop, we need to use the loop's temporary variable. Use {$warn.product_code} Quote Link to comment Share on other sites More sharing options...
keat Posted March 10, 2016 Author Share Posted March 10, 2016 I have been playing for a few hours, mainly trial and much error i'm afraid. I had changed $product.product_code to $warn.product_code, but the table is still empty. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 10, 2016 Share Posted March 10, 2016 Sometimes, it baffles me why the developers chose to query the database asking for the least number of database fields possible, when getting all the fields is not any more difficult to receive or process. Anyway, in this case, there is some necessary preliminary setup for the query structure which prevents asking for everything in the query. In the file /admin/sources/dashboard.index.inc.php, near line 221, find the statement that STARTS WITH: $fields = 'I.name ,I.stock_level AS I_stock_level, Add the new fields as indicated, keeping the rest of the statement as is: $fields = 'I.product_code AS I_product_code, M.product_code AS M_product_code, I.name ,I.stock_level AS I_stock_level, In the file /admin/skins/default/templates/dashboard.index.php, find the statement you just added: <td width="20" align="left"> {$warn.product_code}</td> Change to: <td width="20" align="left">{if $warn.M_use_stock==1}{$warn.M_product_code}{else}{$warn.I_product_code}{/if}</td> Quote Link to comment Share on other sites More sharing options...
keat Posted March 10, 2016 Author Share Posted March 10, 2016 I'd have never figured that out. I got giddy when I thought i'd almost cracked it. I need to play about with the table sizes, (will do this tomorrow at work). Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted March 10, 2016 Share Posted March 10, 2016 Congrats for getting as close as you did on your own, @keat!! You have every reason to feel giddy! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.