CatalogView snippet for MODx Evolution

    I present to you the catalogView snippet . It was created for the new version of Shopkeeper - 1.0 (for MODx Evolution), but now it can be used instead of Ditto .

    I did a little performance test of both snippets. We have 200 documents. Snippets cannot be cached, because paging required. Approximately average values ​​were taken after several page updates.



    Snippet calls:

    [!catalogView?
    &dataType=`documents`
    &tpl=`@FILE:assets/snippets/catalogView/chunks/catalogRow_chunk.tpl`
    &parents=`87`
    &paginate=`1`
    &display=`10`
    &sortBy=`pagetitle`
    &sortDir=`asc`!]


    [!Ditto?
    &tpl=`@FILE:assets/snippets/catalogView/chunks/catalogRow_chunk.tpl`
    &parents=`87`
    &paginate=`1`
    &display=`10`
    &sortBy=`pagetitle`
    &sortDir=`asc`!]


    10 documents per page



    catalogView

    MySQL: 0.0722 s, 6 request (s), PHP: 0.2756 s, total: 0.3479 s, document retrieved from cache


    Ditto

    MySQL: 0.1907 s, 32 request (s), PHP: 0.4672 s, total: 0.6579 s, document retrieved from cache


    20 documents per page



    catalogView

    MySQL: 0.0735 s, 6 request (s), PHP: 0.2934 s, total: 0.3669 s, document retrieved from cache


    Ditto

    MySQL: 0.2601 s, 52 request (s), PHP: 0.5081 s, total: 0.7683 s, document retrieved from cache


    As you can see, Ditto makes 2 MySQL queries for each document on the page. There is one non-standard PHx modifier in the catalogRow_chunk.tpl chunk, which is used to change the format of the price number: [+ price: num_format +] . If you remove it, the values ​​will be like this (20 documents):

    catalogView

    MySQL: 0.0754 s, 5 request (s), PHP: 0.2794 s, total: 0.3548 s, document retrieved from cache


    Ditto

    MySQL: 0.2218 s, 32 request (s), PHP: 0.5411 s, total: 0.7629 s, document retrieved from cache


    Strangely, Ditto began to make significantly fewer requests. There is now one request per document. catalogView - less than one common request. I don’t know what kind of request there is and why PHx does it , because the modifier code is in the file, not in the database, but it doesn’t matter. I was wondering why for each PHx-modifier (non-standard) when using Ditto, one request is made in the database, because PHx caches such modifiers.

    Everything turned out to be simple. Ditto (2.1.0) does not allow PHx to cache modifiers, as when "rendering" each document, it creates a new object of the PHx class (function $ ditto-> render () ). Well, and besides this, if you do not use PHx-modifiers from files, one request per document is too much.

    catalogViewWhile not very well tested, errors are possible. Please report bugs found.

    Download catalogView 1.0 RC1

    PS Of course, it's time to think about MODx Revo, but I decided to “finish off” Shopkeeper for MODx Evo by releasing version 1.0 (now beta).

    Also popular now: