Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    6
    Plugin Contributions
    0

    Default 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.

    PHP Code:
    $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

  2. #2
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: Backslash gets stripped from Product_Model

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

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  3. #3
    Join Date
    Aug 2007
    Posts
    6
    Plugin Contributions
    0

    Default 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 Code:
    echo $pInfo->products_model
    the backslash is missing. I must get stripped before, but I can't see where.

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

    Thanks.
    Bye
    Last edited by LuMe96; 14 Nov 2007 at 08:10 AM.

  4. #4
    Join Date
    Aug 2007
    Posts
    6
    Plugin Contributions
    0

    Default 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 :
    PHP Code:
    $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.

    PHP Code:
    $pInfo->products_model = ($product->fields['products_model']); 
    Thanks anyway.
    Bye.

  5. #5
    Join Date
    Aug 2007
    Posts
    6
    Plugin Contributions
    0

    Default 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.

    Thanks in advance for your kind help.
    Bye

 

 

Similar Threads

  1. Replies: 1
    Last Post: 1 Jun 2010, 02:52 AM
  2. backslashes stripped from product description?
    By scatzc in forum General Questions
    Replies: 14
    Last Post: 6 Nov 2009, 01:38 AM
  3. how to change " getting stripped from page titles?
    By lankeeyankee in forum General Questions
    Replies: 4
    Last Post: 28 Feb 2008, 04:05 PM
  4. Who gets $$ from manual?
    By srleslie in forum General Questions
    Replies: 2
    Last Post: 22 Jul 2007, 09:45 PM
  5. product_model based on attributes
    By duncdamonk in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 21 Sep 2006, 08:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR