Post by jty » Sat Nov 29, 2008 2:57 pm

In admin, Product Options, if a product is set to have option_id = 1 and option_value_id = 10
If you then try and edit that product's options, the drop down list shows option_value_id of 1

To replicate, on a standard install of RC4, in phpmyadmin, change the option_value_id of Large to '1'
so we now have option_value_id for small = 10 and large = 1 both belonging to option_id = 1

Now go to admin and edit Product 1's options
Set the Size Option to be small. Save it
Go back in to edit again and the option value will show large Wrong!
Save it as large anyway, go back in and it shows large. Correct.
But small always turns to large.

Is anyone else having this problem. I tried other other option_values and they're OK. Only option_value_id of 1 is getting confused with 10

... continued
and then option_value_id of 2 gets confused with 20
I give-up  :'(
Last edited by jty on Sat Nov 29, 2008 3:18 pm, edited 1 time in total.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Sat Nov 29, 2008 3:53 pm

Well I see what you are saying, doesn't really affect anything, just resets the default drop down option to Large instead of its current value. But once you save it with the correct value, its fine.

I'll look at the tpl file to see why it is choosing that first

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Sat Nov 29, 2008 3:59 pm

Thanks for confirming that I'm not going insane and seeing things

I know it doesn't affect anything from a code point of view but it can lead to mistakes
If a shop owner wants to simply change something else in there eg the price or sort order and they fail to notice that the option has been switched because the kids are screaming in the background, the dog has escaped and the phone is ringing ...........
it could lead to errors and the shop owner may find himself selling a large thing for the price of a small thing.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Sat Nov 29, 2008 4:09 pm

It's due to the way options are concatenated with the option values for display

It takes
option_id
1

and option_values
10
11
12


and makes
1.10
1.11
1.12


It sorts it as a decimal it seems, so when you change the large from 12 to 1 it becomes

1.10
1.11
1.1

so 1.1 is before 1.10 and 1.11

But still that doesn't explain why it changes it when editing.. but its 2am here and the babies are falling asleep so I am going to sleep too :)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Sat Nov 29, 2008 4:25 pm

Thanks for checking. I'll re-do my database to sidestep the issue
Good night

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Sun Nov 30, 2008 12:27 am

Ok I found the problem.

In the tpl file for:

Code: Select all

<tr>
              <td width="185"><?php echo $entry_option; ?></td>
              <td><select name="option">
                  <?php foreach ($options as $option) { ?>
                  <optgroup label="<?php echo $option['name']; ?>">
                  <?php foreach ($option['value'] as $option_value) { ?>
                 [b][color=red] <?php if ($option_value['option_value_id'] == $option_value_id) { ?>[/color][/b]
                  <option value="<?php echo $option_value['option_value_id']; ?>" selected><?php echo $option_value['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                  </optgroup>
                  <?php } ?>
                </select></td>
            </tr>
It is comparing 1.1 == 1.10.

A simple test of:

Code: Select all

if (1.1 == 1.10) {
            echo "true";
        }
Shows that it does indeed return true.

tried strval on both, but strval converts 1.10 to "1.1" also

Moving this to bug report forum.

Strange, but good find :)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Sun Nov 30, 2008 12:37 am


Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Sun Nov 30, 2008 1:09 am

fixed in r237

To fix it in existing code, global replace all 4 instances of:

Code: Select all

'.'
to

Code: Select all

':'
Last edited by Qphoria on Sun Nov 30, 2008 2:58 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 1 guest