[TYPO3-commerce] Attribute names with allArticles=0

Morten Olesen mo at idefa.dk
Fri Jun 20 12:30:44 CEST 2008


Hi again,

I managed to figure it out!

(Note: This post is mostly relevant for the commerce developers and 
unless otherwise stated this all relates to class.tx_commerce_pi1.php.)

The problem is this the drop downs are generated by 
"get_selectattribute_matrix" this returns a struckture like;

Array
(
     [title] => size
     [unit] =>
     [values] => Array
         (
             [4] => small
			[5] => medium
			[6] => large
         )

     [valueformat] =>
     [Internal_title] =>
     [icon] =>
)


how ever if something _is_ selected
( line ~ 558 : 
"if($this->piVars['attList_'.$prod->get_uid().'_changed']==$attribute_uid){" 
)
"get_attribute_matrix" is used instead and in that flow the array 
structure is altered to this:

Array
(
     [title] => size
     [unit] =>
     [values] => Array
         (
             [4] => Array
                 (
                     [value] => small
                     [icon] =>
                 )

             [5] => Array
                 (
                     [value] => medium
                     [icon] =>
                 )

             [6] => Array
                 (
                     [value] => large
                     [icon] =>
                 )

         )

     [valueformat] =>
     [Internal_title] =>
     [icon] =>
)


This is the cause of the problem since regardless of the data structure 
"['values']['value']" is used for the dropdown's values
  ( line ~ 568  inside the foreach loop )

Due to the way php deals with undefined indexes (['value']) and the way 
it handles strings when accessed as an array we are being given index 0 
for the character array in every case where the user havent just 
selected something from the drop down. ( this is quite clearly a bug in 
commerce )

The easiest way to fix this would be to alter line ~568 : "						 
$val['value'].'</option>';" to
__________________________________________________________________
"";
if (is_array($val) ){
	$attCode.=$val['value'].'</option>';
}else{ // it is with the current implementation a string
	$attCode.$val.'</option>';
}
__________________________________________________________________

ofcourse that is at best a dirty hack - the real question is why does 
the array structure gets altered in this manner in the case where the 
front end user has chosen something in the drop down?


A few lines earlier in line ~556 is where the "all" option gets inserted 
- what purpose does it serve? before anything is selected in the 
dropdowns the first article is shown - would it not make more sence to 
have the drop downs reflect this?

Before I start making the changes for this I'd like to know what the 
guidelines for gettign patches into svn is, as I'm not to keen on 
maintaining a seperate patch set each release.

/Morten

Morten Olesen wrote:
> Hi again,
> 
> More strangeness - in list view if I select the color attribute of any 
> product it will change the selection of any drop downs ( other products 
> ) on that page if those products has that color - but only the dropdown 
> you altered will be shown with it's full name, the others will be show 
> only with the first letter as usual.
> 
> Morten Olesen wrote:
>> Hi newsgroup!
>>
>>
>> so I finally resolved the problem with the attributes generating 
>> javascript errors when the front end user selected anything.
>>
>> So on to the next headacke all attributes are abreviated to just one 
>> letter in the drop downs.
>> Like so; Red,Black,Blue  becomes R,B,B in the select tag
>> once you selected anything there and the page has reloaded the drop 
>> down shows the complete name - but only untill you select something in 
>> another dropdown.
>>
>> Also after selecting anything that becomes the only option for that 
>> drop down.
>>
>> So the questions are:
>>
>> * How do I get the drop downs to display the full attribute name always?
>> * How do I always get the full list of attributes ( or better yet only 
>> the possible combinations; ie linke the dropdowns )
>> * How do I get rid off the "all" entry in the dropdowns
>>
>> /Morten Olesen


More information about the TYPO3-project-commerce mailing list