Bug #39614
valueformat for attributes doesn't work
| 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());
History
Updated by Klaus Lauer 10 months ago
- File tx_commerce-patch-pi1-valueformat.diff added
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());