We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: MackenzieB at Jun 26, 2008, 03:01 AM

    I hear a lot of users say that storing a lot of products in the documents table would make the site slow, but why is that? Is it because of how the manager is built? It’s still the same amount of data when storing in another table no?
    Each document in MODx has metadata that is loaded on every request. So, if you make every product a document, that will decrease your performance based on the quantity of those documents. If you use an external table and present them through a single document (or a couple for different views), then there is no metadata, no loss of performance, and your SQL queries are again king. Your search would have to be custom of course, but you have to weigh the pro’s and con’s of both approaches and decide which is best for your implementation.
      • 17846
      • 17 Posts
      Quote from: OpenGeek at Jun 26, 2008, 10:16 AM

      Each document in MODx has metadata that is loaded on every request. So, if you make every product a document, that will decrease your performance based on the quantity of those documents.
      Thanks Opengeek for your answer. But does this also count for my approach?

      Each product(=document) is allowed to be a separate page that can be accessed directly (the product detail page). In that document I use regular TVs (price, weight,...) and a couple of snippets, for instance to display related products.
      All the snippets contain API calls like getDocument or getTemplateVarOutput to collect data from different documents (I use my own snippets but I could use Ditto for this I guess). The data layout is shaped with chunks.
      So when is the metadata loaded then? Not I hope right? Lately I’ve been dazzled by the ease of use of Modx and all the things the designers have thought of that make this CMS a true toolbox to build anything you want. Yet I’ve never tested performance, since it hasn’t been an issue before, but then again I don’t have +1000 or so documents heavily mashed up.

      Can you give me a typical example of when the metadata is loaded multiple times?
        • 17846
        • 17 Posts
        I didn’t know this question started a new topic by Scotty. I’ll go read that one first smiley
        I think once we clear this out we have found the holy grail to integrate scalable e-commerce with Modx!
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: MackenzieB at Jun 28, 2008, 02:08 AM

          Quote from: OpenGeek at Jun 26, 2008, 10:16 AM

          Each document in MODx has metadata that is loaded on every request. So, if you make every product a document, that will decrease your performance based on the quantity of those documents.
          Thanks Opengeek for your answer. But does this also count for my approach?

          Each product(=document) is allowed to be a separate page that can be accessed directly (the product detail page). In that document I use regular TVs (price, weight,...) and a couple of snippets, for instance to display related products.
          All the snippets contain API calls like getDocument or getTemplateVarOutput to collect data from different documents (I use my own snippets but I could use Ditto for this I guess). The data layout is shaped with chunks.
          So when is the metadata loaded then? Not I hope right? Lately I’ve been dazzled by the ease of use of Modx and all the things the designers have thought of that make this CMS a true toolbox to build anything you want. Yet I’ve never tested performance, since it hasn’t been an issue before, but then again I don’t have +1000 or so documents heavily mashed up.

          Can you give me a typical example of when the metadata is loaded multiple times?
          It absolutely applies to your approach. If you have 1000 products and each product is represented by a MODx document, then on every request to any MODx page, you will be loading the metadata (alias, id, content-type, etc.) for all 1000 documents; that’s 1000 entries in multiple arrays. You can see this manifested in the assets/cache/siteCache.idx.php file. So there is a curve of performance based on the number of total documents you have published in your site definition.
            • 17846
            • 17 Posts
            Quote from: OpenGeek at Jul 03, 2008, 03:10 PM

            You can see this manifested in the assets/cache/siteCache.idx.php file.
            Yes, I’ve been investigating that file. So to make sure I understand this correctly: siteCache.idx.php is generated at each change on the manager end and loaded once at each request on the front end. Since all docs metadata, chunks, snippets etc. is stored in that file, the document parser gets its data from there to minimize database requests? Yet, the more data stored in Modx (directly), the bigger siteCache.idx.php, so there is a turning point where this type of caching no longer benefits performance. (And this issue has been addressed as the +5000 doc limit and will be solved in 0.9.7 ?)

            In another thread you mentioned how to keep snippets as small as possible by including external files. Do you have a similar approach for chunks? I kinda like being able to store my html in a chunk and call it from a snippet. Yet, a lot of chunk data will increase the siteCache.idx.php file size too.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You can include text files into chunks and even the template with a snippet. I am pretty sure somebody has already made one that takes the filename/path as an argument, makes sure the file exists and includes it.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 17846
                • 17 Posts
                I did this in a snippet (which in itself could have been an included php file):

                $chunkName=’path_to_chunk_file/chunkname.chunk.php’; // I stored some chunk content in this file
                $modx->setPlaceHolder("myplaceholder","My Value");
                $output = file_get_contents($chunkName);
                return $output;

                Worked like a charm smiley Thanks for freshing up!
                  • 52
                  • 17 Posts
                  Hello,
                  Quick question about TC, is it possible to have a page that lists multiple products? Something like this http://www.play.com/DVD/DVD/6-/NewReleases.html.

                  Is this something that TC can do natively, or would i have to do this with Ditto?

                  Thanks in advance,
                  Matt
                    • 27330
                    • 884 Posts
                    you need to use both for that, TC for the products details an Ditto to display them. I made a store with TC like that. The idea is to included TC data in the document introtext for example and then use Ditto to display the thumbs/links
                      • 13427
                      • 6 Posts
                      hi to all,

                      i’m new and i’m italian so excuse me for my bad english..

                      I’ve the same problem of member AntonL, my cart work good, but only when i’m logged as admin.

                      Anyone can help me?

                      Thanks to all.

                      Max