ezPublish WebShop Inventory Tracking?

Author Message

Trent Jurewicz

Tuesday 19 February 2008 3:31:48 pm

I am looking to see how inventory can be tracked in the ezPublish WebShop. I'm sure somebody has needed this before. Is it always a custom development? Is there a plugin or add-on? Any information you can offer is appreciated.

Pascal Specht

Wednesday 20 February 2008 1:05:35 am

Hi Trent,

this isn't a built-in feature. But it isn't too much work to do:

add an attribute called quantity (integer) to your product class, and use some code like this one whenever an order has been acknowledged:

function updateQuantities($order)
{
	$productCollection = $order->productCollection();
	$orderedItems = $productCollection->itemList();
	foreach ($orderedItems as $item)
	{
		$contentObject = $item->contentObject();
		$contentObjectVersion =& $contentObject->version($contentObject->attribute('current_version'));
		$contentObjectAttributes =& $contentObjectVersion->contentObjectAttributes();

		// iterate over the attributes
		foreach (array_keys($contentObjectAttributes) as $key)
		{
			$contentObjectAttribute =& $contentObjectAttributes[$key];
			$contentClassAttribute =& $contentObjectAttribute->contentClassAttribute();
			$attributeIdentifier = $contentClassAttribute->attribute("identifier");

			if ($attributeIdentifier == "quantity")
			{
				$newQuantity = $contentObjectAttribute->attribute("value") - $item->ItemCount;

				$contentObjectAttribute->fromString($newQuantity);
				$contentObjectAttribute->store();
			}
		}
	}
}

 

Hope this helps,
</Pascal>

Trent Jurewicz

Wednesday 20 February 2008 9:46:50 am

Thank you for the reply Pascal! Please forgive my noob question, but is the sample code you provided ez template or PHP code?

Thanks!

Pascal Specht

Thursday 21 February 2008 12:26:51 am

Hi Trent,

the code snipped is PHP, and would have to be placed somewhere in a workflow that gets triggered when the purchase is done, typically in the payment gateway, for instance.

</Pascal>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:26:00
Script start
Timing: Jan 31 2025 01:26:00
Module start 'layout'
Timing: Jan 31 2025 01:26:00
Module start 'content'
Timing: Jan 31 2025 01:26:02
Module end 'content'
Timing: Jan 31 2025 01:26:02
Script end

Main resources:

Total runtime1.1188 sec
Peak memory usage8,192.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.1328151.2109
Module start 'layout' 0.00510.0031 739.3438220.7031
Module start 'content' 0.00821.1099 960.04694,424.7578
Module end 'content' 1.11810.0007 5,384.804711.8438
Script end 1.1188  5,396.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3053160.0002
Check MTime0.00120.1087160.0001
Mysql Total
Database connection0.00090.077910.0009
Mysqli_queries1.027891.8640600.0171
Looping result0.00060.0538580.0000
Template Total1.068095.520.5340
Template load0.00230.203720.0011
Template processing1.065795.254220.5329
Template load and register function0.00210.187410.0021
states
state_id_array0.00220.195910.0022
state_identifier_array0.00100.091420.0005
Override
Cache load0.00180.1653210.0001
Sytem overhead
Fetch class attribute can translate value0.00200.180520.0010
Fetch class attribute name0.00240.217650.0005
XML
Image XML parsing0.00090.077120.0004
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00190.1690160.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs