Zen Cart Logo
Forums / Basic Configuration / Backslash gets stripped from Product_Model

Backslash gets stripped from Product_Model

Locked

Views: 1,865

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
13 Nov 2007, 5:41 PM
#1
lume96 avatar

lume96

New Zenner

Join Date:
Aug 2007
Posts:
6
Plugin Contributions:
0

Backslash gets stripped from Product_Model

Hi all,

I'm having the following pb :

Some of our product models have a backslash in their code (ex.: ABC123\1). As these products and their codes are also used in our normal sales software, changing the backslash to something else is no option, so I have to do with them.

The pb is that those backslashes get stripped out (from the Product model field) when opening a product page for modification. So the Product model input field only holds "ABC1231" instead of "ABC123\1". If the person modifying a product does not add the backslash back to the item, the product model code is saved without it.

As far as I could figure out, it gets already stripped out on the SQL query result* , but I've no idea on how to solve this issue.

$product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
                                      p.products_id, p.products_quantity, p.products_model, ...

(file collect_info.php in admin/includes/modules/product, line 46)

Anyone got a solution to this pb ?

Thank's a lot in advance.
Bye

13 Nov 2007, 11:25 PM
#2
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Backslash gets stripped from Product_Model

The usual method is to use 2 backslashes to "unescape"

14 Nov 2007, 7:06 AM
#3
lume96 avatar

lume96

New Zenner

Join Date:
Aug 2007
Posts:
6
Plugin Contributions:
0

Re: Backslash gets stripped from Product_Model

Hi,

Thanks HEM for your reply.

I think the description of my pb wasn't clear enough.

If I create/add a new product, putting a product ID containing a backslash in the Product model field works just fine (I don't even need to unescape the backslash).

The product ID of the newly created product is shown correctly (with the backslash) on the website as well as in the admin interface when I browse the Categories/products (menu CATALOG - CATEGORIES/PRODUCTS).

However, if I edit an existing Product in the Admin interface, the product page is shown and the product data gets "loaded" showing the manufacturer, master category, product name, a.s.o.. The product model also gets loaded, but the backslash gets stripped out. So if the product model was ABC123\23 initially, the product model input field now holds ABC12323. So the person editing/modifying a product needs to put the backslash back in.

I know that the zen function to construct the input field (zen_draw_input_field) calls a stripslashes function but that is not the problem. Even if I replace the input field but a simple ```php
echo $pInfo->products_model;


So if someone has a hint, I would highly appreciate.

Thanks.
Bye
14 Nov 2007, 8:24 AM
#4
lume96 avatar

lume96

New Zenner

Join Date:
Aug 2007
Posts:
6
Plugin Contributions:
0

Re: Backslash gets stripped from Product_Model

hi all,

ok, I did some further testing and searching and finally found a workaround to my problem.

Actually, the query retrieves the data correctly from the db (including the backslash).

The backslash gets lost when the query result gets copied to the $pInfo object :

$pInfo->objectInfo($product->fields);

I do not know any php, so I couldn't really bother further investigating this, however as a simple workaround I added the following line just to reinject the query result on a "field-by-field basis" and here the backslash is maintained.

$pInfo->products_model = ($product->fields['products_model']);

Thanks anyway.
Bye.

16 Nov 2007, 8:48 AM
#5
lume96 avatar

lume96

New Zenner

Join Date:
Aug 2007
Posts:
6
Plugin Contributions:
0

Re: Backslash gets stripped from Product_Model

Hi all,

ok, I need some further help with this. Actually as mentioned above, everything seemed to work fine with my 'patch'. This was until I put Zen-Cart to our hosters web server.

Having done some further investigation, it came out that our hosters web server has magic_quotes off (no way to change this).

Since then, I've been trying to walk through the code of Collect_info.php and preview_info.php, did some other corrections but still can't get the backslash to be maintained in the db.

Not really familiar with php, I just can't seem to find the place where the data actually gets written to the db.

What is working so far is :

  1. The input field shows the backslash (when opening a product for modification)
  2. After some other modifs, the $_POST['products_model'] on preview_info.php holds the backslash (so if, from preview, I go back to the editing the backslash is still there).

Could someone please point out what actually happens when I press the INSERT/UPDATE button on the product preview page ? I really don't know what other code snippets to investigate. :cry:

Thanks in advance for your kind help.
Bye