Jump to content

[Resolved] Show product_code on stock warnings


keat

Recommended Posts

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">&nbsp;</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}
 

Link to comment
Share on other sites

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}

 

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...