Miva Merchant 5 Module FAQs » Inventory Manager 5.x


Displaying and controlling the inventory data

In my Merchant 5.x store the display of the inventory counts and status is not always correct. Especially in cases where we are tracking inventory on individual attributes and the "add to basket" button for the entire product is missing!

The approach originally discussed in the documentation and in prior FAQs had some compatibility issues with the way Merchant was defining variables (eg. setting the variables pointing to a particular attribute even in parts of the process where the product data itself was being displayed.

I have reworked the way the Inventory Manager 5 provides access to its data about inventory for specific products, attributes, & options. Changes to Merchant 5.5 were making it tricky to keep up with. The previous approach of using specific item tokens to display the data may not work in some situations and support of that approach will be sporadic at best.

This new approach populates the l.all_settings variable used by Merchant's component pages to make the data accessible from with the templates in the same way that you can currently access the product data.

To activate this capability requires that you assign the InventoryManager (the item BROK_INVENTORY which was used in previous versions of the module will work as well) item to the particular Merchant page template you want to use the data in (if it isn't already). Then at the top of the product specific template (for example for the "PROD Product Display" page this would be in the template on the "Product Display Layout" tab) put the item token:

<mvt:item name="InventoryManager" param="load_data" />

If you want to access the data from with the display of the product's attributes and options add that same token to the top of the attribute specific template. Again, in the case of the PROD screen this would be the template on the "Product Attribute Template".

With that item in the template you then have access to various l.settings: variables specific to the particular product, attribute, or option:

l.settings:product:im_inventory:error (may contain any error message but not necessarily "fatal" in the case of an item which is not being tracked)
l.settings:product:im_inventory:tracking (will be 1 if tracking is enabled for this item, otherwise 0)

l.settings:product:im_inventory:inv_count (the count of the item "in stock")

l.settings:product:im_inventory:permit_sale (will be set to 1 if the current inventory level is such that the product can be sold, otherwise 0)

l.settings:product:im_inventory:permit_display (will be set to 1 if the current inventory level permits display, otherwise 1)

l.settings:product:im_inventory:level (the current level #)

l.settings:product:im_inventory:level_name (the name of the current level)

l.settings:product:im_inventory:long_message (the "long message" configured for the current level)

l.settings:product:im_inventory:short_message (the "short message" configured for the current level)

l.settings:product:im_inventory:attr_message (the "attribute message" configured for the current level)

The same variables are available for tracked attributes and options:



On the BASK (Basket Contents) screen he l.settings for product data is l.settings:item so the variables become:


These variables can be used in component language conditionals and of course the &mvt tokens that go with them. For example:


This new approach somewhat simplifies the process of using conditionals and displaying data for the individual products and attributes. For example, to hide the "buy" button the product page if the particular product is out of stock first check the "Items" tab of the "Product Display" section in your store's >Pages area to make sure that the module's InventoryManager item is assigned to the page. Then in the template on the "Product Display Layout", at the top, add the item:

<mvt:item name="InventoryManager" param="load_data" />

This will cause the module to be forced to load the variables for the particular product. Lower down in that template you can add the conditional:

<mvt:if expr="l.settings:product:im_inventory:permit_sale"> .... </mvt:if>

to hide the button. For example:

<mvt:if expr="l.settings:product:im_inventory:permit_sale">
<h5>Quantity: </h5><input type="text" name="Quantity" value=1 size=4>
<div id="prodadd"><mvt:item name="buttons" param="AddToBasket" /></div>

which will permit the quantity field and "Add to Basket" button to be displayed only if the inventory level will "permit sale". The usage to hide out-of-stock attributes and options is very similar. For example, to hide out-of-stock radio options place the item:

<mvt:item name="InventoryManager" param="load_data" />

at the top of the "Product Attribute Template" template. Then in the section of code in that template which displays the 'radio' options place the conditional around the code which displays the individual option:

<mvt:if expr="l.settings:option:im_inventory:permit_sale">
<td valign = "middle">
<mvt:if expr="( ( g.Product_Attributes[l.settings:attribute:index]:value EQ 0 ) AND ( l.settings:option:id EQ l.settings:attribute:default_id ) ) OR ( g.Product_Attributes[l.settings:attribute:index]:value EQ l.settings:option:code )">
<input type="radio" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:option:code;" checked>
<input type="radio" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:option:code;">
<td valign = "middle">
<mvt:if expr="l.settings:option:image">
<img src="&mvte:option:image;" alt="&mvte:option:prompt;">

To display the Inventory Manager data on the BASK page add the item token:

<mvt:item name="BROK_INVENTORY" param="load_data" />

at the very top of the template field on the "Basket Contents" tab of the "Basket Contents" screen template. Then inside of the loop:

<mvt:foreach iterator="item" array="basket:items">

put the item variables you want to use, &mvt:item:im_inventory:inv_count;, &mvt:item:im_inventory:short_message;, etc..

It is my intent to keep this FAQ up-to-date with examples so if you would like to see an example of any particular configuration just let me know.

Last update: 2009-08-26 10:11
Author: Michael Brock
Revision: 1.1

Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 3.5 out of 5 (2 Votes )

completely useless 1 2 3 4 5 most valuable

You cannot comment on this entry