Product code doesn't "stick"

Currently on 2.1.1, but this is a problem I’ve had for several versions. When I try to set the Product Code in an Option Combination, sometimes it doesn’t “stick” and I have to go into the db and set it manually, which is not acceptable. Any idea what might be causing this before I dig into the code? Product codes are required for me so I can sync inventory from my store’s POS system item number.



Thanks!

Mark

Hi Brudosm,

The bug you mentioned close to this one:

Can’t update some product code or qty inside the option combinations when more 6 combinations.



please take a look…

Thanks for the info! Any thoughts on why the bug tracker was closed without being resolved. I guess I will work on fixing it myself. Thanks again!

I solved myself…lol



The problem is on $mode == ‘update_combinations’ code block of “controllers/admin/product_options.php”

Thank you very much for trying to help me with this! I see in the bug report you mention that cs-cart made some changes to fix it. Can you post it? Thanks, Mark

The scripts from cs-cart didn’t fix the problem. After 6 weeks long wait, I fixed the CS-Cart option combination hash bug under PHP 5.2.13 by myself.



I found cs-cart option combination hash work well with PHP 5.2.14 on my another site, when hosting upgrade PHP from 5.2.08 → 5.2.14.



Anyway, I will check my records and post my scripts for you tomorrow. Actually, it is just one line code update on product_options.php…lol

Just share what I did:

1.put “T” as prefix for 3 of inventory[T{$i.combination_hash}] in the “skins/basic/admin/views/product_options/inventory.tpl”. This will let PHP treat combination_hash as string.

[QUOTE]



{$lang.product_code}:





{if $product_inventory == “O”}



{$lang.quantity}:





{else}



{/if}



[/QUOTE]



2.Add one line of code:

[QUOTE] $k = substr($k, 1, strlen($k) - 1);[/QUOTE]

below foreach statement in the “controllers/admin/product_options.php” and directly sent it with db_query as string parameter. If you use “combination_hash” as integer index, random negative numbers will come back again!

[QUOTE]if ($mode == ‘update_combinations’) {



// Updating images

fn_attach_image_pairs(‘combinations’, ‘product_option’, 0, array(), ‘product’, $_REQUEST[‘product_id’]);

if (!empty($_REQUEST[‘inventory’])) {

foreach ($_REQUEST[‘inventory’] as $k => $v) {

$k = substr($k, 1, strlen($k) - 1);

db_query(“UPDATE ?:product_options_inventory SET ?u WHERE combination_hash = ?s”, $v, $k);

}

}

$suffix = “.inventory&product_id=$_REQUEST[product_id]”;

}[/QUOTE]

Perfect! Thank You! Now on to a bunch of odd behavior in the gift registries.

o…oh

you need to debug yourself or contact support.