function zen_get_sba_stock_attribute_info($products_id, $attribute_list = array(), $from = 'order')
{
    global $db;
    $attribute_info = array();
    if (isset($attribute_list) && ($k = sizeof($attribute_list)) > 0) {
        $attribute_info['stock_attribute'] = zen_get_sba_stock_attribute($products_id, $attribute_list, $from);
        $query = 'select stock_id from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where `stock_attributes` = "' . $attribute_info['stock_attribute'] . '" and products_id = ' . (int) $products_id;
        $stock_id = $db->Execute($query);
        if (zen_not_null($stock_id) && sizeof($stock_id) > 1) {
            echo 'This is an error situation, as only one record should be returned.  More than one stock id was returned which should not be possible.';
        } else {
            $attribute_info['stock_id'] = $stock_id->fields['stock_id'];
            return $attribute_info;
        }
    }
}
 function updateNotifyOrderProcessingStockDecrementBegin(&$callingClass, $notifier, $paramsArray, &$stock_values, &$attribute_stock_left)
 {
     global $db;
     $this->_stock_values = $stock_values;
     if ($this->_orderIsSBA && $stock_values->RecordCount() > 0) {
         // kuroi: Begin Stock by Attributes additions
         // added to update quantities of products with attributes
         $attribute_search = array();
         $attribute_stock_left = STOCK_REORDER_LEVEL + 1;
         // kuroi: prevent false low stock triggers
         // mc12345678 If the has attibutes then perform the following work.
         if (isset($this->_productI['attributes']) and sizeof($this->_productI['attributes']) > 0) {
             // mc12345678 Identify a list of attributes associated with the product
             $stock_attributes_search = zen_get_sba_stock_attribute(zen_get_prid($this->_productI['id']), $this->_productI['attributes'], 'order');
             $get_quantity_query = 'select quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id="' . zen_get_prid($this->_productI['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
             // mc12345678 Identify the stock available from SBA.
             $attribute_stock_available = $db->Execute($get_quantity_query);
             // mc12345678 Identify the stock remaining for the overall stock by removing the number of the current product from the number available for the attributes_id.
             $attribute_stock_left = $attribute_stock_available->fields['quantity'] - $this->_productI['qty'];
             // mc12345678 Update the SBA table to reflect the stock remaining based on the above.
             $attribute_update_query = 'update ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' set quantity=' . $attribute_stock_left . ' where products_id="' . zen_get_prid($this->_productI['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
             $db->Execute($attribute_update_query);
             $this->_attribute_stock_left = $attribute_stock_left;
         }
     }
 }