Announcement

Collapse
No announcement yet.

Evaluating response from Reporting API module

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

    Evaluating response from Reporting API module

    I have this 2 liner that request a certain report that's for a given category, - best sellers in the last 30 days .:
    <mvt:do file="g.Module_Feature_RPT_DB" name="l.success" value="Report_Load_ID(25, l.settings:reporttest)" />
    report: &mvt:reporttest;<br/>

    I get back a good response, but how do i make sense of the structure of the response? it's just a comma separated list of everything top level.
    using:<mvt:assign name="g.report_elements" value="miva_array_elements( l.settings:reporttest )" />
    and i get 10 elements which makes sense (report is set to return 10 results), but there's more meta data getting returned.

    in googling, i see using miva_array_elements( ) with miva_struct_members( ) is the way to go. But any pointers on how i output this structure as a whole?

    thanks for any help,
    Paul


    #2
    Actually, found this simple solution in a gist.

    <mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.settings:reporttest ), ',', '<br/>' )" />

    &mvt:global:mvt_debug;

    outputs the contents of the structure.

    Comment


      #3
      another thing, usually the member names in return arrays mimic their database field names, so for example since these are products, you should find product:code, product:name, product:id, etc when you run the array in a foreach loop of <mvt:foreach iterator="product" array="reportest">
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment


        #4
        Thanks Bruce, that's very helpful to know.

        In this case it looks like the reporting API returns things a little differently. I think because the return data is meant to generate charts. Here's how it's structured:

        :config:category=cpap-masks-bipap-masks
        :config:chart_topn=10
        :config:customers_in=1
        :config:display_topn=10
        :config:export_topn=10
        :config:metric=gross
        :config:products[1]:code=comfort-gel-blue-nasal-cpap-mask-respironics
        :config:products[1]:name=ComfortGel+Blue+Nasal+CPAP%2FBiPAP+Mask+with +Headgear
        :config:products[1]:set_id=1
        :config:products[1]:total=6151.03
        :config:products[2]:code=dreamwear-cpap-bipap-mask-philips-respironics
        :config:products[2]:name=DreamWear+Nasal+CPAP%2FBiPAP+Mask+with+Headg ear
        :config:products[2]:set_id=2
        :config:products[2]:total=4624.2
        :config:products[3]:code=comfort-gel-blue-full-cpap-bipap-mask-respironics
        :config:products[3]:name=ComfortGel+Blue+Full+Face+CPAP%2FBiPAP+Mask+ with+Headgear
        :config:products[3]:set_id=3
        :config:products[3]:total=4210.68

        thanks again,
        Paul

        Comment

        Working...
        X