-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache all attribute options for display in layered navigation #943 #942
Cache all attribute options for display in layered navigation #943 #942
Conversation
This will improve performance by reducing the amount of SQL Queries when fetching all possible attributes to display in the layered navigation
I may be missing something, but you do not need to add the translate cache tag because updating translations will not have a material affect on the attribute options. You should add the individual id tag as well to be safe. So the final $tags = array_merge(['eav'], $this->getAttribute()->getCacheTags()); |
I included the translate cache tag because Magento also clears it after saving an attribute (with the comment The suggestion you made to use |
I updated the PR to match @colinmollenhour suggestions. I've been using this in production for a couple of months and works well in reducing the number of SQL queries. Of course it will hit the cache backend instead so if it's the database it's not much of a difference but if it's Redis or Memcached it will be better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already tested past days .... LGTM
Hi
SELECT `main_table`.*, `tdv`.`value` AS `default_value`, `tsv`.`value` AS `store_default_value`, IF(tsv.value_id > 0, tsv.value, tdv.value) AS `value` FROM `eav_attribute_option` AS `main_table`
INNER JOIN `eav_attribute_option_value` AS `tdv` ON tdv.option_id = main_table.option_id
LEFT JOIN `eav_attribute_option_value` AS `tsv` ON tsv.option_id = main_table.option_id AND tsv.store_id = '7' WHERE (`attribute_id` = '184') AND (tdv.store_id = 0) ORDER BY main_table.sort_order ASC, value ASC
The same way it's done in
|
@tmotyl A runtime cache usually makes sense because this will not be GCd in the lifetime of the request anyway and memory is cheap. |
@tmotyl I will add a local runtime cache. I only see one call for each attribute on my store so it might be something specific to your store. |
Related to issue #934.
This will improve performance by reducing the amount of SQL Queries when fetching all possible attributes to display in the layered navigation. The amount of queries you will save is related to the amount of attributes you each store has configured to be available for layered navigation.
When saving attributes Magento will clear the translate cache tag so that cache tag as well as the EAV cache tag are included with this cache object.