Announcement

Collapse
No announcement yet.

What happened to g.Product_Code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What happened to g.Product_Code?

    Hi folks,

    One of my clients has a module that uses the value of g.Product_Code to determine whether or not to apply custom behavior on the PROD page. The module stopped working when the client turned on URI Management. Apparently in some cases, g.Product_Code is not initialized any more.

    This was a surprise to me. I've written a lot of modules over the years that use g.Product_Code. Is there a way to get it initialized by changing some admin settings?

    After studying some LSK code, I was able to work out a quick fix by using the value of g.Session:uri:product_id to look up the correct product when g.Product_Code is empty. Is this the recommended practice, or is there a better way? This is a system-ex module, so I can't use template variables, at least not without writing quite a bit of new code.

    If there's some other documentation on this that I missed, please point me to it. Thanks --
    Last edited by Kent Multer; 05-19-16, 08:46 PM.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    The URI subsystem does ensure that g.Product_Code is set, but does so after system extension modules have processed the page, which is why you're not seeing it all the time. Your solution is fine, or you could implement your module as a component assigned to the page. When ComponentModule_Initialize/Render/whatever are called, g.Product_Code will have been initialized.

    Comment


      #3
      Hi Burch, thanks for the info. I've written a lot of sys-ex modules that read g.Product_Code; but come to think of it, most of them are probably taking actions triggered by ADPR. And I assume that, even in a store using short links, any HTML form or link that does an ADPR will still have to explicitly include a Product_Code value. Is that correct?

      Thanks again --
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment

      Working...
      X