Jump to:

2088 Posts in 1008 Topics by 455 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Order table overloaded...

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1160 Views
  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Order table overloaded... Link to this post

    Hi Guys,

    I've got an interesting problem with the orders table in the database. Here's the story so far.

    I have a SS ecommerce website up for a client and they have been unable to get into their orders section in the CMS recieving the "Fatal error: Allowed memory size of 104857600 bytes exhausted (tried to allocate 24 bytes) in /home/fbunda/public_html/sapphire/core/model/MySQLDatabase.php on line 1076". Note: Everything else in the CMS and front-end working without a problem.
    After first approaching the host and having them raise the allocated memory I was still having no luck.
    Reading other forum articles on this I noticed it mentioned that problems like this can be caused by certain anomolies in the database so thought I would have a look.

    The "Order" table has 5,864 entries,
    Order Attribute has 967
    Order Item 490
    Order Modifier 477

    Just being a start up small business with less than 10 orders so far I thought this was pretty abnormal... excuse the understatement

    I believe fixing this will solve my first problem but am very worried by this new problem I have found in the database...

    Does anyone know why this would be happening, has it happened to anyone else, is my client's website the unfortunate target of a hacker...and if so is there a vulnerability in the ecommerce module that needs to be addressed....?

    If anyone could help asap it would be much appreciated.

    Thank you!

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Order table overloaded... Link to this post

    For anyone facing similar issues here is the correspondace and outcome of the above, I received a lot of support from Nicolaas which is much appreciated, but ended up going with Jeremy’s “Shop” branch of ecommerce for the resolution – see below.

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Order table overloaded... Link to this post

    Reply From Nicolaas:

    Hey Snowboarder82

    You should get a lot of orders - that is pretty normal, but they should also be removed after a while. What version of e-commerce are you using?

    You can browse to www.yoursite.com/dev/ecommerce/ and review the options there. That might help?

    On what page are you getting the error? What I am trying to do right now is to make the product selection less memory intensive.

    What are your product settings? Do you have the site on SVN / GIT?

    Cheers

    Nicolaas

    -------------------------------------------------------------------------------

    From Snowboarder82:

    Hi Nicolaas,

    Thank you very much for your quick reply – I definitely appreciate it!
    In answer to your questions:

    What version of e-commerce are you using?
    I am using the "ecommerce module v0.8.1", as well as the "E-commerce Product Variations Colour Extension" from the SSU Demo Site

    You can browse to www.yoursite.com/dev/ecommerce/ and review the options there. That might help?
    Tried to access this but received a server error “Server Error <br /> Sorry, there was a problem handling your request.”…

    On what page are you getting the error? What I am trying to do right now is to make the product selection less memory intensive.
    The memory exhausted error is occurring only while loading the “Orders” page of the CMS.

    What are your product settings?
    I have all of the product settings commented out in the sites mysite/_config.php

    Do you have the site on SVN / GIT?
    No sorry, just copies on my local environment and the live version online. If it would help to have it up somewhere for you to reference please let me know and I’ll get this up asap – if so is there anywhere you would recommend?

    Thank you, again I appreciate you looking into this so promptly Nicolaas.

    Best regards,

    -------------------------------------------------------------------------------

    From Nicolaas:

    Hi Snowboarder82

    I have a few recommendations:

    1. put your site on SVN/ GIT (will save you TONS of time in the long run)

    2. upgrade to either Jeremy's shop or the latest version of e-commerce.

    OR

    go into the Order Class and remove some of the fields in the getCMSfields method to find out where it runs out of memory (which may or may not work)

    OR

    replace the search fields for Order and see if that makes a difference.

    Hope that helps for now.... Hopefully I can come back to you on this one.

    Cheers

    Nicolaas

    Hi Snowboarder82

    The other temp fix you could apply is to delete all the orders from the database that do NOT have any order items associated with them

    DELETE FROM \"Order\" LEFT JOIN \"OrderAttribute\" ON \"OrderAttribute\".\"OrderID\" = \"Order.\"ID\" WHERE \"OrderAttribute\".\"ID\" is NULL; [UNTESTED!]

    -------------------------------------------------------------------------------

    From Snowboarder82
    Hi Nicolaas,

    Thank you for the recommendations and advice for the temp fix to the database.
    I tried the SQL as well as changing the syntax of it but couldn’t get it to work unfortunately… I have attached a copy of the database for your reference. As another idea what are your thoughts about deleting all orders in this instance where country is “NULL” as a quick fix?
    I will look into putting the site on SVN / GIT, and will upgrade to the latest version of ecommerce – just wanted to confirm this is the svn-trunk-r1284 version from the silverstripe.org modules download page, or do I need to go to the code.google.com/p/silverstripe-ecommerce/ downloads section for the latest – For this situation I would prefer the most stable version available?

    Thank you again for your help on this Nicolaas, it is much appreciated!

    -------------------------------------------------------------------------------

    From Nicolaas:

    try https://silverstripe-ecommerce.googlecode.com/svn/branches

    End of correspondence:

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Order table overloaded... Link to this post

    From there I had implemented deleting all orders where country was NULL pretty much the same as deleting any order without a payment connected to it. This temp fix resulted in the “Memory allocation error” disappearing. I then updated to the latest branch of the e-commerce module. I see this as a module with great functionality and commend Nicolaas on his great work here. However because my website was already live and I had integrated it with the ecommerce module pre the SSU / BurnBright separation I encountered a few problems with crossing over to the new SSU branch.
    Plan B – I went and tried integrating with Jeremy's BurnBright “Shop” branch which is very similar to the original ecommerce version I was using with some great improvements. I’ve had success so far with Jeremy’s Shop module and also commend him on his work here, especially with the amount of documentation that has been created for the module.

    So far so good but a few more questions. I’m hoping either Jedateach or Nicolaas could advise on the below?

    1) It seems that every time someone views a page on the website that includes the cart, an order item is created (without even adding an item to the cart). Therefore a huge amount of unnecessary order items gets added to the database – is this normal?

    Note: In some projects I have added the code:

    “function Cart() {
          HTTP::set_cache_age(0);
          return ShoppingCart::current_order();
       }
    }”

    to the main page.php in order to have the cart appear on every page if an item is added. Therefore the order number goes up everytime someone views the site in a new browser session.

    2) Is there any additional housekeeping that anyone implementing these modules needs to be aware of – ie: do we manually need to clear these orders that are created every so often or are empty carts cleared automatically after a duration of time etc?

    Thank you,

  • Jedateach
    Avatar
    Forum Moderator
    227 Posts

    Re: Order table overloaded... Link to this post

    Hi SnowBoarder82,

    In my latest code (for the shop module) I've provided a Cart function on all ContentControllers. In plain english, this means you can reference Cart in your templates, which will access the current order, if it exists. I've also completely rewritten the ShoppingCart class, so now an order only starts when you add something to your cart.

    Yes, because carts are stored in the database, you will probably want to automatically or manually clear out old ones.
    I've started this documentation here, with instructions on automated tasks: http://demo.ss-shop.org/docs/developer/en/SettingUpShop
    ...still needs attention though.

    Hope that helps.

    regards,
    Jeremy

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Order table overloaded... Link to this post

    Thank you for the update Jedateach,

    Wanting to have the cart appear on every one of the website's pages (if an item had been added) I had previously added the Cart function info my mysite/code/page.php like this:

    function Cart() {
          HTTP::set_cache_age(0);
          return ShoppingCart::current_order();
       }

    Even with your changes to the ShoppingCart class i'm assuming that by me having this function in page.php it would still cause an order (in the db) to be created even when nothing has been added??

    I'm using the shop module v0.8.3 and seeing you've provided the cart function on all ContentControllers i've gone ahead and removed this function from page.php, however now trying to reference the Cart in my templates the cart doesn't appear except on my product and product group pages - using the following reference below on mytheme/templates/page.ss:

    <% if Cart.Items %>
          <% include Cart %>
    <% end_if %>

    Am I referencing the Cart correctly? Do I still need to include anything in my page.php to access the cart from every page on the website?

    Thank you,

  • Jedateach
    Avatar
    Forum Moderator
    227 Posts

    Re: Order table overloaded... Link to this post

    The universal $Cart variable is not part of 0.8.3, along with the ShoppingCart rewrite (preventing carts from being created).

    The current code base is pretty stable now, you can download here if you want to try it:
    https://github.com/burnbright/silverstripe-shop/zipball/master

    otherwise, I'll be getting a new release out soon.

  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    Re: Order table overloaded... Link to this post

    Great,

    Thanks for the heads up Jedateach, will look forward to the new release coming out, any idea on an ETA at this stage?
    May look to implement the current available code if time allows.
    Probably a bit of an SS rookie question but, for a few of my projects I have added bits of custom code where needed for specific functionality for clients. So far I have just gone in and made changes to files in the mysite/shop/code folder. Obviously this isn't practicle as any upgrade to the module requires me having to keep track of these changes and re-apply them.
    Like putting the shop templates into the my theme folder where's the best place to put custom code that overrides the modules php files??

    Thanks again,

    1160 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.