Index: pi1/class.tx_commerce_pi1.php =================================================================== --- pi1/class.tx_commerce_pi1.php (revision 33328) +++ pi1/class.tx_commerce_pi1.php (working copy) @@ -549,18 +549,14 @@ // define $arrAttSubmit for finding the right article later $arrAttSubmit = array(); - foreach($this->piVars as $key => $val) { if (strstr($key, 'attsel_') && $val) { - $arrAttSubmit[intval(substr($key, 7))] = intval($val); - if ($this->piVars['attList_' . $prod->getUid() . '_changed'] == intval(substr($key, 7))) { - break; - } //set only if it is the selected product - for listing mode if ($this->piVars['changedProductUid'] == $prod->get_uid() || $this->piVars['showUid'] == $prod->get_uid()) { - $attributeArray[] = array( - 'AttributeUid' => substr($key, 7), 'AttributeValue' => $val - ); + $arrAttSubmit[intval(substr($key, 7))] = intval($val); + if ($this->piVars['attList_' . $prod->getUid() . '_changed'] == intval(substr($key, 7))) { + break; + } } } } @@ -575,7 +571,7 @@ if ($this->conf['allArticles'] || $count == 1) { //@TODO: Correct like this? for($i = 0; $i < $count; $i ++) { - $attributeArray = $prod->get_Atrribute_Matrix(array( + $attributeArray = $prod->getAttributeMatrix(array( $prod->articles_uids[$i] ), $this->select_attributes, $showHiddenValues); if (is_array($attributeArray)) { @@ -668,7 +665,7 @@ $markerArray['###SELECT_ATTRIBUTES_UNIT###'] = $attributeObj->get_unit(); $itemsContent = ''; $i = 1; - $attributeValues = $attributeObj->get_all_values(true); + $attributeValues = $attributeObj->get_all_values(true,$prod); foreach($attributeValues as $val) { // ($this->piVars['changedProductUid'] == $prod->get_uid() && $this->piVars['showUid'] == $prod->get_uid())) Index: lib/class.tx_commerce_product.php =================================================================== --- lib/class.tx_commerce_product.php (revision 33328) +++ lib/class.tx_commerce_product.php (working copy) @@ -378,7 +378,7 @@ * @TODO Create useful and understandable comments in english ... * @param array ( * array('AttributeUid'=>$attributeUID, 'AttributeValue'=>$attributeValue), - * array('AttributeUid'=>$attributreUID, 'AttributeValue'=>$attributeValue), + * array('AttributeUid'=>$attributeUID, 'AttributeValue'=>$attributeValue), * ... * ) * @param Proof if script is running without instance and so without a single product @@ -392,7 +392,6 @@ $first = 1; // Initialize arrays to prevent warningn in array_intersect() - $first_array = array(); $next_array = array(); $addwhere = ''; @@ -418,7 +417,7 @@ $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( 'distinct tx_commerce_articles.uid', - 'tx_commerce_articles ', + 'tx_commerce_articles', 'tx_commerce_articles_article_attributes_mm', 'tx_commerce_attributes', $addwhere . " AND tx_commerce_articles.hidden = 0 and tx_commerce_articles.deleted = 0" . $whereUid @@ -426,11 +425,7 @@ if (($result) && ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0)) { while ($return_data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - if ($first) { - $first_array[] = $return_data['uid']; - } else { - $next_array[] = $return_data['uid']; - } + $next_array[] = $return_data['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } @@ -439,7 +434,7 @@ // Daher das Erste Array setzen und dann mit Array Intersect nur noch die ?bereinstimmungen // behalten. if ($first) { - $attribute_uid_list = $first_array; + $attribute_uid_list = $next_array; $first = 0; } else { $attribute_uid_list = array_intersect($attribute_uid_list, $next_array); @@ -451,7 +446,7 @@ sort($attribute_uid_list); return $attribute_uid_list; } else { - return FALSE; + return array(); } } } Index: lib/class.tx_commerce_attribute.php =================================================================== --- lib/class.tx_commerce_attribute.php (revision 33328) +++ lib/class.tx_commerce_attribute.php (working copy) @@ -143,36 +143,51 @@ } - /** Franz: how do we take care about depencies between attributes? + /** + * Franz: how do we take care about depencies between attributes? * @param returnObjects condition to return the value objects instead of values + * @param productObject return only attribute values that are possible for the given product * @since 21.02.2010 added param returnObjects * @return array values of attribute * * @access public */ - - - function get_all_values($returnObjects = false){ + function get_all_values($returnObjects = false, $productObject = false){ if($this->attributeValuesLoaded === false){ if ($this->attribute_value_uids=$this->conn_db->get_attribute_value_uids($this->uid)){ - foreach ($this->attribute_value_uids as $value_uid){ - $this->attribute_values[$value_uid] = t3lib_div::makeInstance('tx_commerce_attribute_value'); - $this->attribute_values[$value_uid]->init($value_uid,$this->lang_uid); - $this->attribute_values[$value_uid]->load_data(); - - } - $this->attributeValuesLoaded = true; + foreach ($this->attribute_value_uids as $value_uid){ + $this->attribute_values[$value_uid] = t3lib_div::makeInstance('tx_commerce_attribute_value'); + $this->attribute_values[$value_uid]->init($value_uid,$this->lang_uid); + $this->attribute_values[$value_uid]->load_data(); + } + $this->attributeValuesLoaded = true; } } + + $attributeValues = $this->attribute_values; + + // if productObject is a productObject we have to remove the attribute values wich are not possible at all for this product + if(is_object($productObject)) { + $tAttributeValues = array(); + $productSelectAttributeValues = $productObject->get_selectattribute_matrix(false,array($this->uid)); + foreach($attributeValues as $attributeKey => $attributeValue) { + foreach($productSelectAttributeValues[$this->uid]['values'] as $selectAttributeValue) { + if($attributeValue->getUid() == $selectAttributeValue['uid']) { + $tAttributeValues[$attributeKey] = $attributeValue; + } + } + } + $attributeValues = $tAttributeValues; + } + if($returnObjects){ - return $this->attribute_values; + return $attributeValues; } $return_array=array(); - foreach ($this->attribute_values as $value_uid => $one_value){ + foreach ($attributeValues as $value_uid => $one_value){ $return_array[$value_uid]=$one_value->get_value(); - } return $return_array;