Skip to content
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

Fix replace categories when categories are not set as attribute for f… #650

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

JanPetr
Copy link
Contributor

@JanPetr JanPetr commented Oct 31, 2016

…aceting. This sets categories attribute as attribute for faceting automatically.

…aceting. This sets categories attribute as attribute for faceting automatically.
@dmytro-butko
Copy link

dmytro-butko commented Nov 1, 2016

thanks,
I've

  • added 'categories' to Facets config section
  • upgraded to 1.7.2
    And it works!

PS upgrading to 1.7.2 will make ones credentials incorrect (on any config change i.e. save?) as it seems:

- <frontend_type>password</frontend_type>
+ <frontend_type>obscure</frontend_type>

So integration will fail with ERROR Credentials not configured correctly unless you manually re-fill config details in Magento.
Was unexpected but easy to find in logs.

@JanPetr
Copy link
Contributor Author

JanPetr commented Nov 1, 2016

Thanks for info @dmytro-butko,
I'm glad you made it work!

I added the not about Admin API key to release notes - https://github.com/algolia/algoliasearch-magento/releases/tag/1.7.2

@@ -119,15 +130,17 @@ if ($config->isInstantEnabled()) {
$isSearchPage = true;
}

foreach ($facets as $facet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about something like that:

array_in('categories', array_map(function ($facet) {
   return ($facet['attribute']);
}, $facets);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about it as it's harder to read and I had to think for a while what your code does.
And it would be less efficient as it'd always iterate through all $facets and then again until it finds the correct attribute.

@@ -75,6 +75,13 @@ document.addEventListener("DOMContentLoaded", function (event) {
if (algoliaConfig.request.refinementKey.length > 0) {
data.helper.toggleRefine(algoliaConfig.request.refinementKey, algoliaConfig.request.refinementValue);
}

if (algoliaConfig.areCategoriesInFacets === false && algoliaConfig.request.path.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.

Not sure to get this part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to set the refinement only when categories widget does not exists and the user is on category page. Otherwise it breaks down categories hierarchical widget.

@JanPetr JanPetr merged commit 94a176d into develop Nov 14, 2016
@JanPetr JanPetr deleted the fix_replace_categories branch November 14, 2016 14:00
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