Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tarek 9 posts 29 karma points
    Jan 13, 2016 @ 10:47
    Tarek
    0

    Retrieving Products using EntityCollectionService is Very Slow

    Hi Guys,

    Does anyone know why retrieving products using this -

    var collection = EntityCollectionService.GetByKey(new Guid(category.ToString()));

    takes 5 secs to return 100 products?

    Regards, Tarek

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 13, 2016 @ 17:03
    Rusty Swayne
    0

    The EntityCollectionService literally only returns the collection (not the products, invoices, or customers) so I'm not sure what it is slow in your implementation. The line of code you have there queries for a single record from the merchEntityCollection table without doing any joins.

    For the front end of a site, I would suggest not using the service(s) directly.

    If you got your category value from IPublishedContent (Model.Content) you can do,

     var products = Model.Content.GetPropertyValue<IEnumerable<IProductContent>>("category");
    

    You can also use the MerchelloHelper

     var merchello = new MerchelloHelper();
    
     merchello.Query.Product. ....
    
  • Nguyen Hien 52 posts 133 karma points
    Jan 21, 2016 @ 08:24
    Nguyen Hien
    0

    Rusty, I have same issue with Tarek. Currently, I query by category property in Merchello product is very slow.

    With your code: var products = Model.Content.GetPropertyValue<>

    It show error Content is protected level. What is type of Model?

  • Tarek 9 posts 29 karma points
    Jan 27, 2016 @ 00:30
    Tarek
    0

    Hi Rusty,

    Any further tips on improving performance?

    I have similar experience as Hien.

    Regards, Tarek

  • Lee 1130 posts 3088 karma points
    Jan 27, 2016 @ 09:30
    Lee
    0

    Can you confirm you are using the MerchelloHelper to get the products?

    // with data modifiers
    var merchello = new MerchelloHelper();
    
    // or 
    
    // without data modifiers
    var merchello = new MerchelloHelper(false);
    
    var productQuery = merchello.Query.Product;
    

    And if so, this is what's slow?

  • Nguyen Hien 52 posts 133 karma points
    Jan 27, 2016 @ 22:01
    Nguyen Hien
    0

    Hi Lee,

    I want to get all product in a catalog in Merchello like in image

    enter image description here

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 08, 2016 @ 12:31
    Dan Diplo
    0

    I too noticed that the product listing was relatively slow (in latest 1.14.0) on a clean install of Umbraco 7.3.7 (using SQL Server), with the example Bazaar demo site.

    According to the mini-profiler, rendering the product listing page required 15 SQL statements being executed. On a page showing 3 products (the "funny t-shirts category") I noticed that the following SQL was executed 12 times:

    SELECT *
    FROM [merchTaxMethod]
    WHERE ([merchTaxMethod].[productTaxMethod] = @0)   
    
  • Nguyen Hien 52 posts 133 karma points
    Feb 08, 2016 @ 14:30
    Nguyen Hien
    0

    Hi Dan Diplo,

    Did you have solution for this problem?

    Thanks

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 08, 2016 @ 14:32
    Dan Diplo
    0

    No, I just noticed it. It appears to be the way Merchello works - I'm not sure whether it's an issue that can be addressed or just something that is necessary. It will require a Merchello dev to really answer that...

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Feb 08, 2016 @ 17:26
    Rusty Swayne
    0

    Noted and I'll look into it.

    This query should be cached, so I must have an implementation problem somewhere.

    What it's doing is determining if the product needs to have taxes added to it's product price (is a store setting). This would be in the DataModifier chain and not associated with the EntityCollectionService.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Feb 08, 2016 @ 20:45
    Rusty Swayne
    2

    I think I see what is going on here:

    In the Merchello settings, if you set the setting "Set how taxes are applied" to "Product"

    Then Merchello tries to look up the tax method it should use to figure out what additional value should be added to the product price at runtime.

    enter image description here

    To configure this, you must click the on the GatewayProviders -> Taxation tab to designate which tax method should be used and the percentage of tax to be applied.

    enter image description here

    If this is not set, Merchello was trying to find a tax method over and over again for each product. Checking the box resolves it. I've update this In 1.14.1 if it queries and does not find it, a flag is internally set in the TaxationContext indicating that state and the query is subsequently skipped. This resolved the issue in both cases on my local build.

  • Tarek 9 posts 29 karma points
    Feb 09, 2016 @ 01:13
    Tarek
    0

    Hi Rusty,

    Thanks for looking into this.

    Just to be clear ... are code changes required regardless of the above settings.

    We have the following settings currently -

    Settings Set how taxes are applied = Invoice

    Tax Settings Everywhere else: 10%

    Result Slow Product Query

    I tried changing the settings to what you described above. The speed remained unchanged i.e still slow.

    Regards, Tarek

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Feb 09, 2016 @ 01:17
    Rusty Swayne
    0

    That should do it. Can you recycle your application pool to ensure the TaxationContext is updated. If that is still slow, please post your code.

    The following does not return products. This is a single record read from the merchEntityCollection table.

     var collection = EntityCollectionService.GetByKey(new Guid(category.ToString()));
    
  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 09, 2016 @ 08:49
    Dan Diplo
    1

    Nice work, Rusty! I tested the upgraded and I can no longer see the multiple SQL queries being generated when setting "taxes applied" to Product.

    NB. For people wanting to test this and aren't sure how you need to:

    In web.config set debug="true" in the <compilation> element

    Then append ?umbDebug=true querystring to the page you are debugging.

    You should then see the mini-profiler pop-up at top-right of your page. If you expand it you should see any SQL queries that are generated.

    Note: refresh page a couple of times to allow for caching, as often the first run of a query won't be cached but it will be on subsequent runs.

Please Sign in or register to post replies

Write your reply to:

Draft