CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Bug #39614

valueformat for attributes doesn't work

Added by Klaus Lauer 10 months ago. Updated 10 months ago.

Status:New Start date:2012-08-08
Priority:Should have Due date:
Assignee:- % Done:

0%

Category:Bug Spent time: -
Target version:-
Votes: 0

Description

Version 0.13.4

Trying to use Attributes with integer representation doesn't work. In class.tx_commerce_pi1.php on line 579 the attribute value is assigned to marker '###SELECT_ATTRIBUTES_VALUE###' without formatting.

Assumed workaround is to proof if $myAttribute['valueformat'] is set and then format the attribute value using sprintf().

--- pi1/class.tx_commerce_pi1.php   2012-08-02 10:31:12.000000000 +0200
+++ trunk/pi1/class.tx_commerce_pi1.php 2012-08-08 11:13:20.000000000 +0200
@@ -576,7 +576,12 @@
                            if (is_array($v) && isset($v['value']) && $v['value'] != '') {
                                $v = $v['value'];               
                            }                           
-                           $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = $v;
+                           // check if valueformat is set ###KL### 
+                           if (isset($myAttribute['valueformat'])) {
+                               $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = sprintf($myAttribute['valueformat'], $v);
+                           } else {                    
+                               $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = $v;
+                           }                           
                            $markerArray["###SELECT_ATTRIBUTES_UNIT###"] = $myAttribute['unit'];
                            $numTemplate = $ct % $countTemplateInterations;
                            $attCode .= $this->substituteMarkerArrayNoCached($templateAttr[$numTemplate], $markerArray, array());

tx_commerce-patch-pi1-valueformat.diff (1.1 kB) Klaus Lauer, 2012-08-08 11:43

tx_commerce-patch-pi1-valueformat.diff (1.2 kB) Klaus Lauer, 2012-08-08 12:15

History

Updated by Klaus Lauer 10 months ago

There is also a little bug in my first solution: the test determining if 'valueformat' has to be used should not only make use of isset but also check if valueformat contains a value. Sorry about...

--- pi1/class.tx_commerce_pi1.php   2012-08-02 10:31:12.000000000 +0200
+++ trunk/pi1/class.tx_commerce_pi1.php 2012-08-08 11:07:28.000000000 +0200
@@ -576,7 +576,12 @@
                            if (is_array($v) && isset($v['value']) && $v['value'] != '') {
                                $v = $v['value'];               
                            }                           
-                           $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = $v;
+                           // check if valueformat is set ###KL### 
+                           if (isset($myAttribute['valueformat']) && ($myAttribute['valueformat'] != "")) {
+                               $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = sprintf($myAttribute['valueformat'], $v);
+                           } else {                    
+                               $markerArray["###SELECT_ATTRIBUTES_VALUE###"] = $v;
+                           }                           
                            $markerArray["###SELECT_ATTRIBUTES_UNIT###"] = $myAttribute['unit'];
                            $numTemplate = $ct % $countTemplateInterations;
                            $attCode .= $this->substituteMarkerArrayNoCached($templateAttr[$numTemplate], $markerArray, array());

Also available in: Atom PDF