0

We are generating an XML file everyday detailing the cartthrob orders for the day. The format of this XML is awkward as it needs to repeat certain content at different points as well as a host of conditionals.

I chose stash to record all the orders, stash the main content along with a couple of nested items for cart variations and all works well until we hit upwards of 50 orders.

The server is set to 256MB and now we're getting Server Gone Away Error: 2006. The client has noted that max_allowed_packet=8M and the entire database is only 4M - so this error could be a false negative ?

Upping the ram suppressed that previous error now we're getting server 500 errors.

I have NFI on how to proceed or what to address. The template is as skinny as I can make it. I tried swapping some initial capture tags with {exp:query} and savings were minimal.

This is the basic concept of the XML template that works fine until 50+ orders are being recorded:

{stash:set_list} //set the list
{exp:channel:entries disable="categories|etc"} //query the orders channel
  {stash:first_name} //stash the content
  {stash:lastname}
  {stash:nested_list}
    {order_items} //Grab ordered variations stored in CartThrob matrix
      {stash:qty}
      {stash:color}
      {stash:price}
    {/order_items}
  {/stash:nested}
{/exp:channel:entries}
{/exp:stash:set_list}

Then we build the XML
<xml>
{exp:stash:get_list} //set above, repeat for each order
<customer>
{first_name}
{last_name}
<order_items>
{stash:get_list:nested} //grab the ordered items
  {qty}
  {price}
  {etc…}
{/stash:get_list:nested}
</order_items>
<somepreviousitem>{first_name}</somepreviousitem>
</customer>
{/exp:stash:get_list}
</xml>

Simplistically what can I try to improve this situation? Is there a way to set a batch of sorts ?

Output profiler doesn't help the XML is a template and the extra code breaks the output. Tried BiopsEE but server is running PHP 5.2.17 and required 5.3 - cant change it.

  • I would set your outside set_list to save to the database and look at what's being written to see if it's what you intend. You might then try a higher parse_depth (than 1) and see if that helps. – Romans-8---31-39 May 15 '13 at 14:13
  • Thx, the whole page works well, parse_depth etc are all recording exactly what is required. The issue is more a memory management issue. – stuartmcd69 May 16 '13 at 0:07
1

I generate XML files for orders for clients in a very similar format - I use {exp:query sql=""}...{/exp:query} for the lot. Eg, I don't touch any exp:channel / order:items / embeds etc. Can spit out ~1500 orders and relevant details in no time - We have a separate function that can run live currency conversion on the order totals in these XML files - whilst that's slower as it connects to a google api, we've never had any memory issues.

If you temporarily change the template format out of XML and back to PHP. What does the output profiler say about where your memory limits are being consumed?

  • Does exp:query work just like channel entries inthat you can refer to custom fields the same way? So strip out exp:channel:entries and replace with "get all within date range" query and all code in place should work ? – stuartmcd69 May 17 '13 at 4:19
  • Custom fields, yes - just need to look up the relevant field in exp_channe_data or exp_matrix_data. Date Range - you can use WHERE entry_date >= 'UNIXDATEHERE' AND entry_Date <= 'UNIXDATEHERE'. You could create a simple form that posts the date from a date range selector so users could specify - or you could simply use a {segment_xx} variable to hard code some options in, last month, last 3 months etc. – Jamie Taylor May 17 '13 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.