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>
|