Skip to content

Conversation

damcou
Copy link
Contributor

@damcou damcou commented Oct 17, 2018

Remove "ors" category links when the categories facet is not active

@damcou
Copy link
Contributor Author

damcou commented Oct 17, 2018

Copy link
Contributor

@JanPetr JanPetr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good initiative, @damcou! I added 2 comments.

if (keys.length > 1) {
ors += ', <span><a href="' + keys[1].url + '">' + keys[1].key + '</a></span>';
if (isCategoryFacetEnabled) {
if (keys.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can those 2 conditions be replaced by a cycle?

@@ -336,12 +336,21 @@ document.addEventListener("DOMContentLoaded", function (e) {

var ors = '';

if (keys.length > 0) {
ors += '<span><a href="' + keys[0].url + '">' + keys[0].key + '</a></span>';
var isCategoryFacetEnabled = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the conditions happening no matter if there are some keys or not, which is not super effective. Can it be run only if some keys are present? Or can keys be retrieved only if categories are in facets? It's not effective to do both :)

Copy link
Contributor

@JanPetr JanPetr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @damcou! I noticed one more thing - added to a comment.

ors += ', <span><a href="' + keys[1].url + '">' + keys[1].key + '</a></span>';
var orsTab = [];
for (var i = 0; i<algoliaConfig.facets.length; i++) {
if (algoliaConfig.facets[i].attribute == "categories") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if and for to check if categories are present are redundant to for on line 324. It's already checked that categories are present. If they wouldn't, keys would be an empty array.
So lines 341, 342, 347 (break;) can be removed.

At the same time, could you add spaces to for arguments?:

for (var i = 0; i < keys.length && i < 2 ; i++)

Copy link
Contributor

@JanPetr JanPetr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bsuravech bsuravech merged commit 8f4fd56 into develop Dec 11, 2018
@bsuravech bsuravech deleted the fix-autocomplete-bottom-links branch December 11, 2018 17:27
rbrown added a commit to rbrown/algoliasearch-magento that referenced this pull request Jan 15, 2019
* master: (39 commits)
  Bump to 1.15.0 (algolia#1088)
  Fix error with configuration save while query rules are disabled in Algolia engine (algolia#1077)
  Fix special prices when customer groups are enabled (algolia#1071)
  Fix autocomplete bottom links (algolia#1066)
  update version number on mysql upgrade file
  update grid default direction asc on jobId
  Exclude non-salable subproducts from price calculation (algolia#1075)
  Improve name of "Remove inactive products" indexer (algolia#1054)
  Bump to 1.14.1 (algolia#1073)
  Remove color facet query rule (algolia#1072)
  PR updates - add view action link for indexing queue grid and add additional job methods to the list
  match updated logging in queue
  feedback fixes and add archive table
  long form array update
  indexing queue statuses notification
  Indexing Queue Status preliminary
  update to indexing queue job view
  add clearQueue method to Queue model and add preliminary viewAction for queue/job item view
  preliminary indexing queue controller, block, entity
  update getQueueInfo method for readable structure
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants