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. ....
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;
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)
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...
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.
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.
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.
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.
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
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 fromIPublishedContent
(Model.Content) you can do,You can also use the
MerchelloHelper
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?
Hi Rusty,
Any further tips on improving performance?
I have similar experience as Hien.
Regards, Tarek
Can you confirm you are using the MerchelloHelper to get the products?
And if so, this is what's slow?
Hi Lee,
I want to get all product in a catalog in Merchello like in image
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:
Hi Dan Diplo,
Did you have solution for this problem?
Thanks
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...
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.
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.
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.
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.
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
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.
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>
elementThen 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.
is working on a reply...