{docurl}
Is there a "helper" function which I can MvDO with my script to retrieve and update Inventory data?
(2004/09/09)Yes. The module contains a function which can be MvDOne for this:
InventoryManager_process(task, product_id, attr_string, quantity)
Where:
'product_id' is the product's id which you are retrieving data for
'attr_string" is the tracked item's "attribute string" (which identifies the tracked attributes), if any. It has to be in the format:
[attribute id]=option id,[attribute id2]=option id, etc.
'quantity' is the inventory count to which you want to update the prdouct (if the "task" is "change_level" then the quantity is the level to which the item's assigned level is to be changed to)
'task' can be multiple different things depending on the action you want to take (note that not all fields of the function call are used by all tasks; eg. the value passed in "quantity" matters only when the task is 'adjust_count'):
count returns the current inventory count for product_id
long_message returns the product's current level's long message
short_message returns the product's current level's short message
permit_display reutrns 1 if the product's current level permits display, 0 otherwise
permit_sale returns 1 if the product's current level permits sale, 0 otherwise
level_name returns the current inventory level (name)
level returns the current inventory level (id). If the current level is "none", returns 0
tracking returns 1 if the items inventory is being tracked, 0 otherwise
update_level_all updates ALL product's current level to match their inventory.
update_level update the product's current level to match it's current inventory (used for updating the level if your import does not import the current level).
adjust_count changes the product's current inventory count to the value passed in 'quantity'. The current level is automatically updated accordingly. If the item is in "simple mode" it will be switched out of that mode into regular tracking.
change_level changes the items level to whatever value is passed in the quantity field. If the item is not currently in "simple" mode it will be changed to "simple". This can be used to change the inventory level when using simple tracking.
structure returns a structure for product_id (with most fields corresponding to the tasks described above):
varname:product_id
varname:attr_string
varname:error
varname:count
varname:level
varname:level_name
varname:permit_sale
varname:permit_display
varname:tracking
Eg. the code:
<MvDO FILE="BROK_INVENTORY.mvc" NAME="l.structure" VALUE="{InventoryManager_process('structure', l.product_id, l.attr_string, 0)}">
would populate the variable l.structure as a Miva structure with the members listed above.
If the function encounters an error it returns that error as text (of the form 'ERROR: description') or passes it in the structure member error (eg. l.varname:error).
Last update: 2005-01-12 09:11
Author: Support
Revision: 1.0
You cannot comment on this entry
Records in this category
- I have select and radio type attributes in my store and I'm tracking the inventory of each option. However, when all of the attributes are out of stock, the prompt for the attribute still displays but without any options (and an empty drop down list for "select" type attributes). Can this be fixed?
- Is it possible to display the inventory message for attributes? Most notably, for "select" and "Radio" type attributes? Is there any way to not display the attribute if it is out of stock?
- I'd like to display "in stock" for my products whenever their inventory level is above 0. Can this be done?
- Is there a "helper" function which I can MvDO with my script to retrieve and update Inventory data?
- I just installed Inventory Manager and my inventory levels do not appear to be working. What am I doing wrong?
- Is it possible to display the inventory count on the basket and invoice pages (and other checkout screens)?














